<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-2"></span><span class="hs-comment">--</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- Stg to C--: heap management functions</span><span>
</span><span id="line-4"></span><span class="hs-comment">--</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- (c) The University of Glasgow 2004-2006</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.StgToCmm.Heap</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-12"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#getVirtHp"><span class="hs-identifier">getVirtHp</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#setVirtHp"><span class="hs-identifier">setVirtHp</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#setRealHp"><span class="hs-identifier">setRealHp</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Layout.html#getHpRelOffset"><span class="hs-identifier">getHpRelOffset</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#entryHeapCheck"><span class="hs-identifier">entryHeapCheck</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#altHeapCheck"><span class="hs-identifier">altHeapCheck</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#noEscapeHeapCheck"><span class="hs-identifier">noEscapeHeapCheck</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#altHeapCheckReturnsTo"><span class="hs-identifier">altHeapCheckReturnsTo</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#heapStackCheckGen"><span class="hs-identifier">heapStackCheckGen</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#entryHeapCheck%27"><span class="hs-identifier">entryHeapCheck'</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#mkStaticClosureFields"><span class="hs-identifier">mkStaticClosureFields</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#mkStaticClosure"><span class="hs-identifier">mkStaticClosure</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#allocDynClosure"><span class="hs-identifier">allocDynClosure</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#allocDynClosureCmm"><span class="hs-identifier">allocDynClosureCmm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#allocHeapClosure"><span class="hs-identifier">allocHeapClosure</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.StgToCmm.Heap.html#emitSetDynHdr"><span class="hs-identifier">emitSetDynHdr</span></a></span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator">(&lt;*&gt;)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html"><span class="hs-identifier">GHC.Stg.Syntax</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.CLabel.html"><span class="hs-identifier">GHC.Cmm.CLabel</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Layout.html"><span class="hs-identifier">GHC.StgToCmm.Layout</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Utils.html"><span class="hs-identifier">GHC.StgToCmm.Utils</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html"><span class="hs-identifier">GHC.StgToCmm.Monad</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html"><span class="hs-identifier">GHC.StgToCmm.Prof</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Prof.html#profDynAlloc"><span class="hs-identifier">profDynAlloc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html#dynProfHdr"><span class="hs-identifier">dynProfHdr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Prof.html#staticProfHdr"><span class="hs-identifier">staticProfHdr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Ticky.html"><span class="hs-identifier">GHC.StgToCmm.Ticky</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Closure.html"><span class="hs-identifier">GHC.StgToCmm.Closure</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Env.html"><span class="hs-identifier">GHC.StgToCmm.Env</span></a></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html"><span class="hs-identifier">GHC.Cmm.Graph</span></a></span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Label</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html"><span class="hs-identifier">GHC.Runtime.Heap.Layout</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Utils.html"><span class="hs-identifier">GHC.Cmm.Utils</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.CostCentre.html"><span class="hs-identifier">GHC.Types.CostCentre</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html"><span class="hs-identifier">GHC.Types.Id.Info</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#CafInfo"><span class="hs-identifier">CafInfo</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#mayHaveCafRefs"><span class="hs-identifier">mayHaveCafRefs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier">Id</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.html"><span class="hs-identifier">GHC.Unit</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier">mkFastString</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier">fsLit</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Panic.html"><span class="hs-identifier">GHC.Utils.Panic</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Panic.Plain.html#sorry"><span class="hs-identifier">sorry</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier">when</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier">isJust</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-comment">-----------------------------------------------------------</span><span>
</span><span id="line-57"></span><span class="hs-comment">--              Initialise dynamic heap objects</span><span>
</span><span id="line-58"></span><span class="hs-comment">-----------------------------------------------------------</span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#allocDynClosure"><span class="hs-identifier hs-type">allocDynClosure</span></a></span><span>
</span><span id="line-61"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-62"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmInfoTable"><span class="hs-identifier hs-type">CmmInfoTable</span></a></span><span>
</span><span id="line-63"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Types.html#LambdaFormInfo"><span class="hs-identifier hs-type">LambdaFormInfo</span></a></span><span>
</span><span id="line-64"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>              </span><span class="hs-comment">-- Cost Centre to stick in the object</span><span>
</span><span id="line-65"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>              </span><span class="hs-comment">-- Cost Centre to blame for this alloc</span><span>
</span><span id="line-66"></span><span>                                </span><span class="hs-comment">-- (usually the same; sometimes &quot;OVERHEAD&quot;)</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.StgToCmm.Closure.html#NonVoid"><span class="hs-identifier hs-type">NonVoid</span></a></span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#VirtualHpOffset"><span class="hs-identifier hs-type">VirtualHpOffset</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- Offsets from start of object</span><span>
</span><span id="line-69"></span><span>                                                </span><span class="hs-comment">-- ie Info ptr has offset zero.</span><span>
</span><span id="line-70"></span><span>                                                </span><span class="hs-comment">-- No void args in here</span><span>
</span><span id="line-71"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-comment">-- returns Hp+n</span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#allocDynClosureCmm"><span class="hs-identifier hs-type">allocDynClosureCmm</span></a></span><span>
</span><span id="line-74"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmInfoTable"><span class="hs-identifier hs-type">CmmInfoTable</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Types.html#LambdaFormInfo"><span class="hs-identifier hs-type">LambdaFormInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-75"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-76"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-comment">-- returns Hp+n</span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-comment">-- allocDynClosure allocates the thing in the heap,</span><span>
</span><span id="line-79"></span><span class="hs-comment">-- and modifies the virtual Hp to account for this.</span><span>
</span><span id="line-80"></span><span class="hs-comment">-- The second return value is the graph that sets the value of the</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- returned LocalReg, which should point to the closure after executing</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- the graph.</span><span>
</span><span id="line-83"></span><span>
</span><span id="line-84"></span><span class="hs-comment">-- allocDynClosure returns an (Hp+8) CmmExpr, and hence the result is</span><span>
</span><span id="line-85"></span><span class="hs-comment">-- only valid until Hp is changed.  The caller should assign the</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- result to a LocalReg if it is required to remain live.</span><span>
</span><span id="line-87"></span><span class="hs-comment">--</span><span>
</span><span id="line-88"></span><span class="hs-comment">-- The reason we don't assign it to a LocalReg here is that the caller</span><span>
</span><span id="line-89"></span><span class="hs-comment">-- is often about to call regIdInfo, which immediately assigns the</span><span>
</span><span id="line-90"></span><span class="hs-comment">-- result of allocDynClosure to a new temp in order to add the tag.</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- So by not generating a LocalReg here we avoid a common source of</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- new temporaries and save some compile time.  This can be quite</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- significant - see test T4801.</span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span>
</span><span id="line-96"></span><span id="allocDynClosure"><span class="annot"><span class="annottext">allocDynClosure :: Maybe Id
-&gt; CmmInfoTable
-&gt; LambdaFormInfo
-&gt; CmmExpr
-&gt; CmmExpr
-&gt; [(NonVoid StgArg, Int)]
-&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#allocDynClosure"><span class="hs-identifier hs-var hs-var">allocDynClosure</span></a></span></span><span> </span><span id="local-6989586621681055494"><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681055494"><span class="hs-identifier hs-var">mb_id</span></a></span></span><span> </span><span id="local-6989586621681055493"><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055493"><span class="hs-identifier hs-var">info_tbl</span></a></span></span><span> </span><span id="local-6989586621681055492"><span class="annot"><span class="annottext">LambdaFormInfo
</span><a href="#local-6989586621681055492"><span class="hs-identifier hs-var">lf_info</span></a></span></span><span> </span><span id="local-6989586621681055491"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055491"><span class="hs-identifier hs-var">use_cc</span></a></span></span><span> </span><span id="local-6989586621681055490"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055490"><span class="hs-identifier hs-var">_blame_cc</span></a></span></span><span> </span><span id="local-6989586621681055489"><span class="annot"><span class="annottext">[(NonVoid StgArg, Int)]
</span><a href="#local-6989586621681055489"><span class="hs-identifier hs-var">args_w_offsets</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681055488"><span class="annot"><span class="annottext">[NonVoid StgArg]
</span><a href="#local-6989586621681055488"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681055487"><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681055487"><span class="hs-identifier hs-var">offsets</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(NonVoid StgArg, Int)] -&gt; ([NonVoid StgArg], [Int])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(NonVoid StgArg, Int)]
</span><a href="#local-6989586621681055489"><span class="hs-identifier hs-var">args_w_offsets</span></a></span><span>
</span><span id="line-98"></span><span>  </span><span id="local-6989586621681055485"><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681055485"><span class="hs-identifier hs-var">cmm_args</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(NonVoid StgArg -&gt; FCode CmmExpr)
-&gt; [NonVoid StgArg] -&gt; FCode [CmmExpr]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">NonVoid StgArg -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Env.html#getArgAmode"><span class="hs-identifier hs-var">getArgAmode</span></a></span><span> </span><span class="annot"><span class="annottext">[NonVoid StgArg]
</span><a href="#local-6989586621681055488"><span class="hs-identifier hs-var">args</span></a></span><span>     </span><span class="hs-comment">-- No void args</span><span>
</span><span id="line-99"></span><span>  </span><span class="annot"><span class="annottext">Maybe Id
-&gt; CmmInfoTable
-&gt; LambdaFormInfo
-&gt; CmmExpr
-&gt; CmmExpr
-&gt; [(CmmExpr, Int)]
-&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#allocDynClosureCmm"><span class="hs-identifier hs-var">allocDynClosureCmm</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681055494"><span class="hs-identifier hs-var">mb_id</span></a></span><span> </span><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055493"><span class="hs-identifier hs-var">info_tbl</span></a></span><span> </span><span class="annot"><span class="annottext">LambdaFormInfo
</span><a href="#local-6989586621681055492"><span class="hs-identifier hs-var">lf_info</span></a></span><span>
</span><span id="line-100"></span><span>                     </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055491"><span class="hs-identifier hs-var">use_cc</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055490"><span class="hs-identifier hs-var">_blame_cc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CmmExpr] -&gt; [Int] -&gt; [(CmmExpr, Int)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681055485"><span class="hs-identifier hs-var">cmm_args</span></a></span><span> </span><span class="annot"><span class="annottext">[Int]
</span><a href="#local-6989586621681055487"><span class="hs-identifier hs-var">offsets</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span>
</span><span id="line-103"></span><span id="allocDynClosureCmm"><span class="annot"><span class="annottext">allocDynClosureCmm :: Maybe Id
-&gt; CmmInfoTable
-&gt; LambdaFormInfo
-&gt; CmmExpr
-&gt; CmmExpr
-&gt; [(CmmExpr, Int)]
-&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#allocDynClosureCmm"><span class="hs-identifier hs-var hs-var">allocDynClosureCmm</span></a></span></span><span> </span><span id="local-6989586621681055482"><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681055482"><span class="hs-identifier hs-var">mb_id</span></a></span></span><span> </span><span id="local-6989586621681055481"><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055481"><span class="hs-identifier hs-var">info_tbl</span></a></span></span><span> </span><span id="local-6989586621681055480"><span class="annot"><span class="annottext">LambdaFormInfo
</span><a href="#local-6989586621681055480"><span class="hs-identifier hs-var">lf_info</span></a></span></span><span> </span><span id="local-6989586621681055479"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055479"><span class="hs-identifier hs-var">use_cc</span></a></span></span><span> </span><span id="local-6989586621681055478"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055478"><span class="hs-identifier hs-var">_blame_cc</span></a></span></span><span> </span><span id="local-6989586621681055477"><span class="annot"><span class="annottext">[(CmmExpr, Int)]
</span><a href="#local-6989586621681055477"><span class="hs-identifier hs-var">amodes_w_offsets</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-104"></span><span>  </span><span class="hs-comment">-- SAY WHAT WE ARE ABOUT TO DO</span><span>
</span><span id="line-105"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681055476"><span class="annot"><span class="annottext">rep :: SMRep
</span><a href="#local-6989586621681055476"><span class="hs-identifier hs-var hs-var">rep</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmInfoTable -&gt; SMRep
</span><a href="GHC.Cmm.html#cit_rep"><span class="hs-identifier hs-var hs-var">cit_rep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055481"><span class="hs-identifier hs-var">info_tbl</span></a></span><span>
</span><span id="line-106"></span><span>  </span><span class="annot"><span class="annottext">Maybe Id -&gt; SMRep -&gt; LambdaFormInfo -&gt; FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyDynAlloc"><span class="hs-identifier hs-var">tickyDynAlloc</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681055482"><span class="hs-identifier hs-var">mb_id</span></a></span><span> </span><span class="annot"><span class="annottext">SMRep
</span><a href="#local-6989586621681055476"><span class="hs-identifier hs-var">rep</span></a></span><span> </span><span class="annot"><span class="annottext">LambdaFormInfo
</span><a href="#local-6989586621681055480"><span class="hs-identifier hs-var">lf_info</span></a></span><span>
</span><span id="line-107"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681055473"><span class="annot"><span class="annottext">info_ptr :: CmmExpr
</span><a href="#local-6989586621681055473"><span class="hs-identifier hs-var hs-var">info_ptr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabel -&gt; CmmLit
</span><a href="GHC.Cmm.Expr.html#CmmLabel"><span class="hs-identifier hs-var">CmmLabel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmInfoTable -&gt; CLabel
</span><a href="GHC.Cmm.html#cit_lbl"><span class="hs-identifier hs-var hs-var">cit_lbl</span></a></span><span> </span><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055481"><span class="hs-identifier hs-var">info_tbl</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span>  </span><span class="annot"><span class="annottext">SMRep -&gt; CmmExpr -&gt; CmmExpr -&gt; [(CmmExpr, Int)] -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#allocHeapClosure"><span class="hs-identifier hs-var">allocHeapClosure</span></a></span><span> </span><span class="annot"><span class="annottext">SMRep
</span><a href="#local-6989586621681055476"><span class="hs-identifier hs-var">rep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055473"><span class="hs-identifier hs-var">info_ptr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055479"><span class="hs-identifier hs-var">use_cc</span></a></span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, Int)]
</span><a href="#local-6989586621681055477"><span class="hs-identifier hs-var">amodes_w_offsets</span></a></span><span>
</span><span id="line-109"></span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="hs-comment">-- | Low-level heap object allocation.</span><span>
</span><span id="line-112"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#allocHeapClosure"><span class="hs-identifier hs-type">allocHeapClosure</span></a></span><span>
</span><span id="line-113"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#SMRep"><span class="hs-identifier hs-type">SMRep</span></a></span><span>                            </span><span class="hs-comment">-- ^ representation of the object</span><span>
</span><span id="line-114"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>                          </span><span class="hs-comment">-- ^ info pointer</span><span>
</span><span id="line-115"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>                          </span><span class="hs-comment">-- ^ cost centre</span><span>
</span><span id="line-116"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>              </span><span class="hs-comment">-- ^ payload</span><span>
</span><span id="line-117"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>                    </span><span class="hs-comment">-- ^ returns the address of the object</span><span>
</span><span id="line-118"></span><span id="allocHeapClosure"><span class="annot"><span class="annottext">allocHeapClosure :: SMRep -&gt; CmmExpr -&gt; CmmExpr -&gt; [(CmmExpr, Int)] -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#allocHeapClosure"><span class="hs-identifier hs-var hs-var">allocHeapClosure</span></a></span></span><span> </span><span id="local-6989586621681055469"><span class="annot"><span class="annottext">SMRep
</span><a href="#local-6989586621681055469"><span class="hs-identifier hs-var">rep</span></a></span></span><span> </span><span id="local-6989586621681055468"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055468"><span class="hs-identifier hs-var">info_ptr</span></a></span></span><span> </span><span id="local-6989586621681055467"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055467"><span class="hs-identifier hs-var">use_cc</span></a></span></span><span> </span><span id="local-6989586621681055466"><span class="annot"><span class="annottext">[(CmmExpr, Int)]
</span><a href="#local-6989586621681055466"><span class="hs-identifier hs-var">payload</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-119"></span><span>  </span><span class="annot"><span class="annottext">SMRep -&gt; CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Prof.html#profDynAlloc"><span class="hs-identifier hs-var">profDynAlloc</span></a></span><span> </span><span class="annot"><span class="annottext">SMRep
</span><a href="#local-6989586621681055469"><span class="hs-identifier hs-var">rep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055467"><span class="hs-identifier hs-var">use_cc</span></a></span><span>
</span><span id="line-120"></span><span>
</span><span id="line-121"></span><span>  </span><span id="local-6989586621681055465"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055465"><span class="hs-identifier hs-var">virt_hp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Int
</span><a href="GHC.StgToCmm.Monad.html#getVirtHp"><span class="hs-identifier hs-var">getVirtHp</span></a></span><span>
</span><span id="line-122"></span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-comment">-- Find the offset of the info-ptr word</span><span>
</span><span id="line-124"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681055462"><span class="annot"><span class="annottext">info_offset :: Int
</span><a href="#local-6989586621681055462"><span class="hs-identifier hs-var hs-var">info_offset</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055465"><span class="hs-identifier hs-var">virt_hp</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-125"></span><span>            </span><span class="hs-comment">-- info_offset is the VirtualHpOffset of the first</span><span>
</span><span id="line-126"></span><span>            </span><span class="hs-comment">-- word of the new object</span><span>
</span><span id="line-127"></span><span>            </span><span class="hs-comment">-- Remember, virtHp points to last allocated word,</span><span>
</span><span id="line-128"></span><span>            </span><span class="hs-comment">-- ie 1 *before* the info-ptr word of new object.</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span>  </span><span id="local-6989586621681055460"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055460"><span class="hs-identifier hs-var">base</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; FCode CmmExpr
</span><a href="GHC.StgToCmm.Layout.html#getHpRelOffset"><span class="hs-identifier hs-var">getHpRelOffset</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055462"><span class="hs-identifier hs-var">info_offset</span></a></span><span>
</span><span id="line-131"></span><span>  </span><span class="annot"><span class="annottext">FastString -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitComment"><span class="hs-identifier hs-var">emitComment</span></a></span><span> </span><span class="annot"><span class="annottext">(FastString -&gt; FCode ()) -&gt; FastString -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#mkFastString"><span class="hs-identifier hs-var">mkFastString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;allocHeapClosure&quot;</span></span><span>
</span><span id="line-132"></span><span>  </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#emitSetDynHdr"><span class="hs-identifier hs-var">emitSetDynHdr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055460"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055468"><span class="hs-identifier hs-var">info_ptr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055467"><span class="hs-identifier hs-var">use_cc</span></a></span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span>  </span><span class="hs-comment">-- Fill in the fields</span><span>
</span><span id="line-135"></span><span>  </span><span class="annot"><span class="annottext">CmmExpr -&gt; [(CmmExpr, Int)] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#hpStore"><span class="hs-identifier hs-var">hpStore</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055460"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, Int)]
</span><a href="#local-6989586621681055466"><span class="hs-identifier hs-var">payload</span></a></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span>  </span><span class="hs-comment">-- Bump the virtual heap pointer</span><span>
</span><span id="line-138"></span><span>  </span><span id="local-6989586621681055457"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055457"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-139"></span><span>  </span><span class="annot"><span class="annottext">Int -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#setVirtHp"><span class="hs-identifier hs-var">setVirtHp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055465"><span class="hs-identifier hs-var">virt_hp</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; SMRep -&gt; Int
</span><a href="GHC.Runtime.Heap.Layout.html#heapClosureSizeW"><span class="hs-identifier hs-var">heapClosureSizeW</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055457"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">SMRep
</span><a href="#local-6989586621681055469"><span class="hs-identifier hs-var">rep</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-140"></span><span>
</span><span id="line-141"></span><span>  </span><span class="annot"><span class="annottext">CmmExpr -&gt; FCode CmmExpr
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055460"><span class="hs-identifier hs-var">base</span></a></span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span>
</span><span id="line-144"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#emitSetDynHdr"><span class="hs-identifier hs-type">emitSetDynHdr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-145"></span><span id="emitSetDynHdr"><span class="annot"><span class="annottext">emitSetDynHdr :: CmmExpr -&gt; CmmExpr -&gt; CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#emitSetDynHdr"><span class="hs-identifier hs-var hs-var">emitSetDynHdr</span></a></span></span><span> </span><span id="local-6989586621681055454"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055454"><span class="hs-identifier hs-var">base</span></a></span></span><span> </span><span id="local-6989586621681055453"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055453"><span class="hs-identifier hs-var">info_ptr</span></a></span></span><span> </span><span id="local-6989586621681055452"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055452"><span class="hs-identifier hs-var">ccs</span></a></span></span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681055451"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055451"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-147"></span><span>       </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681055450"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681055450"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055451"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-148"></span><span>       </span><span class="annot"><span class="annottext">CmmExpr -&gt; [(CmmExpr, Int)] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#hpStore"><span class="hs-identifier hs-var">hpStore</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055454"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CmmExpr] -&gt; [Int] -&gt; [(CmmExpr, Int)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; [CmmExpr]
</span><a href="#local-6989586621681055448"><span class="hs-identifier hs-var">header</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055451"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Int
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBytes"><span class="hs-identifier hs-var">platformWordSizeInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055450"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-glyph">..</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-150"></span><span>    </span><span class="annot"><a href="#local-6989586621681055448"><span class="hs-identifier hs-type">header</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-151"></span><span>    </span><span id="local-6989586621681055448"><span class="annot"><span class="annottext">header :: DynFlags -&gt; [CmmExpr]
</span><a href="#local-6989586621681055448"><span class="hs-identifier hs-var hs-var">header</span></a></span></span><span> </span><span id="local-6989586621681055446"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055446"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055453"><span class="hs-identifier hs-var">info_ptr</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[CmmExpr] -&gt; [CmmExpr] -&gt; [CmmExpr]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; [CmmExpr]
</span><a href="GHC.StgToCmm.Prof.html#dynProfHdr"><span class="hs-identifier hs-var">dynProfHdr</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055446"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055452"><span class="hs-identifier hs-var">ccs</span></a></span><span>
</span><span id="line-152"></span><span>        </span><span class="hs-comment">-- ToDo: Parallel stuff</span><span>
</span><span id="line-153"></span><span>        </span><span class="hs-comment">-- No ticky header</span><span>
</span><span id="line-154"></span><span>
</span><span id="line-155"></span><span class="hs-comment">-- Store the item (expr,off) in base[off]</span><span>
</span><span id="line-156"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#hpStore"><span class="hs-identifier hs-type">hpStore</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-157"></span><span id="hpStore"><span class="annot"><span class="annottext">hpStore :: CmmExpr -&gt; [(CmmExpr, Int)] -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#hpStore"><span class="hs-identifier hs-var hs-var">hpStore</span></a></span></span><span> </span><span id="local-6989586621681055445"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055445"><span class="hs-identifier hs-var">base</span></a></span></span><span> </span><span id="local-6989586621681055444"><span class="annot"><span class="annottext">[(CmmExpr, Int)]
</span><a href="#local-6989586621681055444"><span class="hs-identifier hs-var">vals</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-158"></span><span>  </span><span id="local-6989586621681055443"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055443"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-159"></span><span>  </span><span class="annot"><span class="annottext">[FCode ()] -&gt; FCode ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a.
(Foldable t, Monad m) =&gt;
t (m a) -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#sequence_"><span class="hs-identifier hs-var">sequence_</span></a></span><span> </span><span class="annot"><span class="annottext">([FCode ()] -&gt; FCode ()) -&gt; [FCode ()] -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-160"></span><span>    </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitStore"><span class="hs-identifier hs-var">emitStore</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; Int -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetB"><span class="hs-identifier hs-var">cmmOffsetB</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055443"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055445"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055438"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055437"><span class="hs-identifier hs-var">val</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681055437"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055437"><span class="hs-identifier hs-var">val</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681055438"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055438"><span class="hs-identifier hs-var">off</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(CmmExpr, Int)]
</span><a href="#local-6989586621681055444"><span class="hs-identifier hs-var">vals</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-161"></span><span>
</span><span id="line-162"></span><span class="hs-comment">-----------------------------------------------------------</span><span>
</span><span id="line-163"></span><span class="hs-comment">--              Layout of static closures</span><span>
</span><span id="line-164"></span><span class="hs-comment">-----------------------------------------------------------</span><span>
</span><span id="line-165"></span><span>
</span><span id="line-166"></span><span class="hs-comment">-- Make a static closure, adding on any extra padding needed for CAFs,</span><span>
</span><span id="line-167"></span><span class="hs-comment">-- and adding a static link field if necessary.</span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#mkStaticClosureFields"><span class="hs-identifier hs-type">mkStaticClosureFields</span></a></span><span>
</span><span id="line-170"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-171"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.html#CmmInfoTable"><span class="hs-identifier hs-type">CmmInfoTable</span></a></span><span>
</span><span id="line-172"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.CostCentre.html#CostCentreStack"><span class="hs-identifier hs-type">CostCentreStack</span></a></span><span>
</span><span id="line-173"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#CafInfo"><span class="hs-identifier hs-type">CafInfo</span></a></span><span>
</span><span id="line-174"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">]</span><span>             </span><span class="hs-comment">-- Payload</span><span>
</span><span id="line-175"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">]</span><span>             </span><span class="hs-comment">-- The full closure</span><span>
</span><span id="line-176"></span><span id="mkStaticClosureFields"><span class="annot"><span class="annottext">mkStaticClosureFields :: DynFlags
-&gt; CmmInfoTable
-&gt; CostCentreStack
-&gt; CafInfo
-&gt; [CmmLit]
-&gt; [CmmLit]
</span><a href="GHC.StgToCmm.Heap.html#mkStaticClosureFields"><span class="hs-identifier hs-var hs-var">mkStaticClosureFields</span></a></span></span><span> </span><span id="local-6989586621681055436"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055436"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681055435"><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055435"><span class="hs-identifier hs-var">info_tbl</span></a></span></span><span> </span><span id="local-6989586621681055434"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681055434"><span class="hs-identifier hs-var">ccs</span></a></span></span><span> </span><span id="local-6989586621681055433"><span class="annot"><span class="annottext">CafInfo
</span><a href="#local-6989586621681055433"><span class="hs-identifier hs-var">caf_refs</span></a></span></span><span> </span><span id="local-6989586621681055432"><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055432"><span class="hs-identifier hs-var">payload</span></a></span></span><span>
</span><span id="line-177"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; CLabel
-&gt; CostCentreStack
-&gt; [CmmLit]
-&gt; [CmmLit]
-&gt; [CmmLit]
-&gt; [CmmLit]
-&gt; [CmmLit]
</span><a href="GHC.StgToCmm.Heap.html#mkStaticClosure"><span class="hs-identifier hs-var">mkStaticClosure</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055436"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681055431"><span class="hs-identifier hs-var">info_lbl</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681055434"><span class="hs-identifier hs-var">ccs</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055432"><span class="hs-identifier hs-var">payload</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055430"><span class="hs-identifier hs-var">padding</span></a></span><span>
</span><span id="line-178"></span><span>        </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055429"><span class="hs-identifier hs-var">static_link_field</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055428"><span class="hs-identifier hs-var">saved_info_field</span></a></span><span>
</span><span id="line-179"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-180"></span><span>    </span><span id="local-6989586621681055427"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681055427"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055436"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-181"></span><span>    </span><span id="local-6989586621681055431"><span class="annot"><span class="annottext">info_lbl :: CLabel
</span><a href="#local-6989586621681055431"><span class="hs-identifier hs-var hs-var">info_lbl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmInfoTable -&gt; CLabel
</span><a href="GHC.Cmm.html#cit_lbl"><span class="hs-identifier hs-var hs-var">cit_lbl</span></a></span><span> </span><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055435"><span class="hs-identifier hs-var">info_tbl</span></a></span><span>
</span><span id="line-182"></span><span>
</span><span id="line-183"></span><span>    </span><span class="hs-comment">-- CAFs must have consistent layout, regardless of whether they</span><span>
</span><span id="line-184"></span><span>    </span><span class="hs-comment">-- are actually updatable or not.  The layout of a CAF is:</span><span>
</span><span id="line-185"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-186"></span><span>    </span><span class="hs-comment">--        3 saved_info</span><span>
</span><span id="line-187"></span><span>    </span><span class="hs-comment">--        2 static_link</span><span>
</span><span id="line-188"></span><span>    </span><span class="hs-comment">--        1 indirectee</span><span>
</span><span id="line-189"></span><span>    </span><span class="hs-comment">--        0 info ptr</span><span>
</span><span id="line-190"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-191"></span><span>    </span><span class="hs-comment">-- the static_link and saved_info fields must always be in the</span><span>
</span><span id="line-192"></span><span>    </span><span class="hs-comment">-- same place.  So we use isThunkRep rather than closureUpdReqd</span><span>
</span><span id="line-193"></span><span>    </span><span class="hs-comment">-- here:</span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span>    </span><span id="local-6989586621681055426"><span class="annot"><span class="annottext">is_caf :: Bool
</span><a href="#local-6989586621681055426"><span class="hs-identifier hs-var hs-var">is_caf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SMRep -&gt; Bool
</span><a href="GHC.Runtime.Heap.Layout.html#isThunkRep"><span class="hs-identifier hs-var">isThunkRep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmInfoTable -&gt; SMRep
</span><a href="GHC.Cmm.html#cit_rep"><span class="hs-identifier hs-var hs-var">cit_rep</span></a></span><span> </span><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055435"><span class="hs-identifier hs-var">info_tbl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span>    </span><span id="local-6989586621681055430"><span class="annot"><span class="annottext">padding :: [CmmLit]
</span><a href="#local-6989586621681055430"><span class="hs-identifier hs-var hs-var">padding</span></a></span></span><span>
</span><span id="line-198"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055426"><span class="hs-identifier hs-var">is_caf</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[CmmLit] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055432"><span class="hs-identifier hs-var">payload</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Platform -&gt; Int -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#mkIntCLit"><span class="hs-identifier hs-var">mkIntCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055427"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
</span><span id="line-199"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-200"></span><span>
</span><span id="line-201"></span><span>    </span><span id="local-6989586621681055429"><span class="annot"><span class="annottext">static_link_field :: [CmmLit]
</span><a href="#local-6989586621681055429"><span class="hs-identifier hs-var hs-var">static_link_field</span></a></span></span><span>
</span><span id="line-202"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055426"><span class="hs-identifier hs-var">is_caf</span></a></span><span>
</span><span id="line-203"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Platform -&gt; Int -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#mkIntCLit"><span class="hs-identifier hs-var">mkIntCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055427"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
</span><span id="line-204"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; CmmInfoTable -&gt; Bool
</span><a href="GHC.StgToCmm.Closure.html#staticClosureNeedsLink"><span class="hs-identifier hs-var">staticClosureNeedsLink</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CafInfo -&gt; Bool
</span><a href="GHC.Types.Id.Info.html#mayHaveCafRefs"><span class="hs-identifier hs-var">mayHaveCafRefs</span></a></span><span> </span><span class="annot"><span class="annottext">CafInfo
</span><a href="#local-6989586621681055433"><span class="hs-identifier hs-var">caf_refs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CmmInfoTable
</span><a href="#local-6989586621681055435"><span class="hs-identifier hs-var">info_tbl</span></a></span><span>
</span><span id="line-205"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmLit
</span><a href="#local-6989586621681055419"><span class="hs-identifier hs-var">static_link_value</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-206"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-207"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span>    </span><span id="local-6989586621681055428"><span class="annot"><span class="annottext">saved_info_field :: [CmmLit]
</span><a href="#local-6989586621681055428"><span class="hs-identifier hs-var hs-var">saved_info_field</span></a></span></span><span>
</span><span id="line-210"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055426"><span class="hs-identifier hs-var">is_caf</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Platform -&gt; Int -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#mkIntCLit"><span class="hs-identifier hs-var">mkIntCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055427"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
</span><span id="line-211"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-212"></span><span>
</span><span id="line-213"></span><span>        </span><span class="hs-comment">-- For a static constructor which has NoCafRefs, we set the</span><span>
</span><span id="line-214"></span><span>        </span><span class="hs-comment">-- static link field to a non-zero value so the garbage</span><span>
</span><span id="line-215"></span><span>        </span><span class="hs-comment">-- collector will ignore it.</span><span>
</span><span id="line-216"></span><span>    </span><span id="local-6989586621681055419"><span class="annot"><span class="annottext">static_link_value :: CmmLit
</span><a href="#local-6989586621681055419"><span class="hs-identifier hs-var hs-var">static_link_value</span></a></span></span><span>
</span><span id="line-217"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CafInfo -&gt; Bool
</span><a href="GHC.Types.Id.Info.html#mayHaveCafRefs"><span class="hs-identifier hs-var">mayHaveCafRefs</span></a></span><span> </span><span class="annot"><span class="annottext">CafInfo
</span><a href="#local-6989586621681055433"><span class="hs-identifier hs-var">caf_refs</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Int -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#mkIntCLit"><span class="hs-identifier hs-var">mkIntCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055427"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-218"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Int -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#mkIntCLit"><span class="hs-identifier hs-var">mkIntCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055427"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span>  </span><span class="hs-comment">-- No CAF refs</span><span>
</span><span id="line-219"></span><span>                                      </span><span class="hs-comment">-- See Note [STATIC_LINK fields]</span><span>
</span><span id="line-220"></span><span>                                      </span><span class="hs-comment">-- in rts/sm/Storage.h</span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#mkStaticClosure"><span class="hs-identifier hs-type">mkStaticClosure</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.CLabel.html#CLabel"><span class="hs-identifier hs-type">CLabel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.CostCentre.html#CostCentreStack"><span class="hs-identifier hs-type">CostCentreStack</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-223"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-type">CmmLit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-224"></span><span id="mkStaticClosure"><span class="annot"><span class="annottext">mkStaticClosure :: DynFlags
-&gt; CLabel
-&gt; CostCentreStack
-&gt; [CmmLit]
-&gt; [CmmLit]
-&gt; [CmmLit]
-&gt; [CmmLit]
-&gt; [CmmLit]
</span><a href="GHC.StgToCmm.Heap.html#mkStaticClosure"><span class="hs-identifier hs-var hs-var">mkStaticClosure</span></a></span></span><span> </span><span id="local-6989586621681055418"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055418"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681055417"><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681055417"><span class="hs-identifier hs-var">info_lbl</span></a></span></span><span> </span><span id="local-6989586621681055416"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681055416"><span class="hs-identifier hs-var">ccs</span></a></span></span><span> </span><span id="local-6989586621681055415"><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055415"><span class="hs-identifier hs-var">payload</span></a></span></span><span> </span><span id="local-6989586621681055414"><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055414"><span class="hs-identifier hs-var">padding</span></a></span></span><span> </span><span id="local-6989586621681055413"><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055413"><span class="hs-identifier hs-var">static_link_field</span></a></span></span><span> </span><span id="local-6989586621681055412"><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055412"><span class="hs-identifier hs-var">saved_info_field</span></a></span></span><span>
</span><span id="line-225"></span><span>  </span><span class="hs-glyph">=</span><span>  </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CLabel -&gt; CmmLit
</span><a href="GHC.Cmm.Expr.html#CmmLabel"><span class="hs-identifier hs-var">CmmLabel</span></a></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681055417"><span class="hs-identifier hs-var">info_lbl</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-226"></span><span>  </span><span class="annot"><span class="annottext">[CmmLit] -&gt; [CmmLit] -&gt; [CmmLit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CostCentreStack -&gt; [CmmLit]
</span><a href="GHC.StgToCmm.Prof.html#staticProfHdr"><span class="hs-identifier hs-var">staticProfHdr</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055418"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621681055416"><span class="hs-identifier hs-var">ccs</span></a></span><span>
</span><span id="line-227"></span><span>  </span><span class="annot"><span class="annottext">[CmmLit] -&gt; [CmmLit] -&gt; [CmmLit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055415"><span class="hs-identifier hs-var">payload</span></a></span><span>
</span><span id="line-228"></span><span>  </span><span class="annot"><span class="annottext">[CmmLit] -&gt; [CmmLit] -&gt; [CmmLit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055414"><span class="hs-identifier hs-var">padding</span></a></span><span>
</span><span id="line-229"></span><span>  </span><span class="annot"><span class="annottext">[CmmLit] -&gt; [CmmLit] -&gt; [CmmLit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055413"><span class="hs-identifier hs-var">static_link_field</span></a></span><span>
</span><span id="line-230"></span><span>  </span><span class="annot"><span class="annottext">[CmmLit] -&gt; [CmmLit] -&gt; [CmmLit]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmLit]
</span><a href="#local-6989586621681055412"><span class="hs-identifier hs-var">saved_info_field</span></a></span><span>
</span><span id="line-231"></span><span>
</span><span id="line-232"></span><span class="hs-comment">-----------------------------------------------------------</span><span>
</span><span id="line-233"></span><span class="hs-comment">--              Heap overflow checking</span><span>
</span><span id="line-234"></span><span class="hs-comment">-----------------------------------------------------------</span><span>
</span><span id="line-235"></span><span>
</span><span id="line-236"></span><span class="hs-comment">{- Note [Heap checks]
   ~~~~~~~~~~~~~~~~~~
Heap checks come in various forms.  We provide the following entry
points to the runtime system, all of which use the native C-- entry
convention.

  * gc() performs garbage collection and returns
    nothing to its caller

  * A series of canned entry points like
        r = gc_1p( r )
    where r is a pointer.  This performs gc, and
    then returns its argument r to its caller.

  * A series of canned entry points like
        gcfun_2p( f, x, y )
    where f is a function closure of arity 2
    This performs garbage collection, keeping alive the
    three argument ptrs, and then tail-calls f(x,y)

These are used in the following circumstances

* entryHeapCheck: Function entry
    (a) With a canned GC entry sequence
        f( f_clo, x:ptr, y:ptr ) {
             Hp = Hp+8
             if Hp &gt; HpLim goto L
             ...
          L: HpAlloc = 8
             jump gcfun_2p( f_clo, x, y ) }
     Note the tail call to the garbage collector;
     it should do no register shuffling

    (b) No canned sequence
        f( f_clo, x:ptr, y:ptr, ...etc... ) {
          T: Hp = Hp+8
             if Hp &gt; HpLim goto L
             ...
          L: HpAlloc = 8
             call gc()  -- Needs an info table
             goto T }

* altHeapCheck: Immediately following an eval
  Started as
        case f x y of r { (p,q) -&gt; rhs }
  (a) With a canned sequence for the results of f
       (which is the very common case since
       all boxed cases return just one pointer
           ...
           r = f( x, y )
        K:      -- K needs an info table
           Hp = Hp+8
           if Hp &gt; HpLim goto L
           ...code for rhs...

        L: r = gc_1p( r )
           goto K }

        Here, the info table needed by the call
        to gc_1p should be the *same* as the
        one for the call to f; the C-- optimiser
        spots this sharing opportunity)

   (b) No canned sequence for results of f
       Note second info table
           ...
           (r1,r2,r3) = call f( x, y )
        K:
           Hp = Hp+8
           if Hp &gt; HpLim goto L
           ...code for rhs...

        L: call gc()    -- Extra info table here
           goto K

* generalHeapCheck: Anywhere else
  e.g. entry to thunk
       case branch *not* following eval,
       or let-no-escape
  Exactly the same as the previous case:

        K:      -- K needs an info table
           Hp = Hp+8
           if Hp &gt; HpLim goto L
           ...

        L: call gc()
           goto K
-}</span><span>
</span><span id="line-325"></span><span>
</span><span id="line-326"></span><span class="hs-comment">--------------------------------------------------------------</span><span>
</span><span id="line-327"></span><span class="hs-comment">-- A heap/stack check at a function or thunk entry point.</span><span>
</span><span id="line-328"></span><span>
</span><span id="line-329"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#entryHeapCheck"><span class="hs-identifier hs-type">entryHeapCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Closure.html#ClosureInfo"><span class="hs-identifier hs-type">ClosureInfo</span></a></span><span>
</span><span id="line-330"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span> </span><span class="hs-comment">-- Function (closure environment)</span><span>
</span><span id="line-331"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>            </span><span class="hs-comment">-- Arity -- not same as len args b/c of voids</span><span>
</span><span id="line-332"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- Non-void args (empty for thunk)</span><span>
</span><span id="line-333"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-334"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-335"></span><span>
</span><span id="line-336"></span><span id="entryHeapCheck"><span class="annot"><span class="annottext">entryHeapCheck :: ClosureInfo
-&gt; Maybe LocalReg -&gt; Int -&gt; [LocalReg] -&gt; FCode () -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#entryHeapCheck"><span class="hs-identifier hs-var hs-var">entryHeapCheck</span></a></span></span><span> </span><span id="local-6989586621681055411"><span class="annot"><span class="annottext">ClosureInfo
</span><a href="#local-6989586621681055411"><span class="hs-identifier hs-var">cl_info</span></a></span></span><span> </span><span id="local-6989586621681055410"><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681055410"><span class="hs-identifier hs-var">nodeSet</span></a></span></span><span> </span><span id="local-6989586621681055409"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055409"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span id="local-6989586621681055408"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055408"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621681055407"><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681055407"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-337"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; CmmExpr -&gt; Int -&gt; [LocalReg] -&gt; FCode () -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#entryHeapCheck%27"><span class="hs-identifier hs-var">entryHeapCheck'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055406"><span class="hs-identifier hs-var">is_fastf</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055405"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055409"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055408"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681055407"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-338"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-339"></span><span>    </span><span id="local-6989586621681055405"><span class="annot"><span class="annottext">node :: CmmExpr
</span><a href="#local-6989586621681055405"><span class="hs-identifier hs-var hs-var">node</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="#local-6989586621681055410"><span class="hs-identifier hs-var">nodeSet</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-340"></span><span>              </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681055404"><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681055404"><span class="hs-identifier hs-var">r</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg
</span><a href="#local-6989586621681055404"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-341"></span><span>              </span><span class="annot"><span class="annottext">Maybe LocalReg
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabel -&gt; CmmLit
</span><a href="GHC.Cmm.Expr.html#CmmLabel"><span class="hs-identifier hs-var">CmmLabel</span></a></span><span> </span><span class="annot"><span class="annottext">(CLabel -&gt; CmmLit) -&gt; CLabel -&gt; CmmLit
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ClosureInfo -&gt; CLabel
</span><a href="GHC.StgToCmm.Closure.html#staticClosureLabel"><span class="hs-identifier hs-var">staticClosureLabel</span></a></span><span> </span><span class="annot"><span class="annottext">ClosureInfo
</span><a href="#local-6989586621681055411"><span class="hs-identifier hs-var">cl_info</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-342"></span><span>
</span><span id="line-343"></span><span>    </span><span id="local-6989586621681055406"><span class="annot"><span class="annottext">is_fastf :: Bool
</span><a href="#local-6989586621681055406"><span class="hs-identifier hs-var hs-var">is_fastf</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ClosureInfo -&gt; Maybe (Int, ArgDescr)
</span><a href="GHC.StgToCmm.Closure.html#closureFunInfo"><span class="hs-identifier hs-var">closureFunInfo</span></a></span><span> </span><span class="annot"><span class="annottext">ClosureInfo
</span><a href="#local-6989586621681055411"><span class="hs-identifier hs-var">cl_info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-344"></span><span>                 </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Types.html#ArgGen"><span class="hs-identifier hs-type">ArgGen</span></a></span><span> </span><span class="annot"><span class="annottext">Liveness
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-345"></span><span>                 </span><span id="local-6989586621681055398"><span class="annot"><span class="annottext">Maybe (Int, ArgDescr)
</span><a href="#local-6989586621681055398"><span class="hs-identifier hs-var">_otherwise</span></a></span></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-346"></span><span>
</span><span id="line-347"></span><span class="hs-comment">-- | lower-level version for &quot;GHC.Cmm.Parser&quot;</span><span>
</span><span id="line-348"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#entryHeapCheck%27"><span class="hs-identifier hs-type">entryHeapCheck'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>           </span><span class="hs-comment">-- is a known function pattern</span><span>
</span><span id="line-349"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>        </span><span class="hs-comment">-- expression for the closure pointer</span><span>
</span><span id="line-350"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>            </span><span class="hs-comment">-- Arity -- not same as len args b/c of voids</span><span>
</span><span id="line-351"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- Non-void args (empty for thunk)</span><span>
</span><span id="line-352"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-353"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-354"></span><span id="entryHeapCheck%27"><span class="annot"><span class="annottext">entryHeapCheck' :: Bool -&gt; CmmExpr -&gt; Int -&gt; [LocalReg] -&gt; FCode () -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#entryHeapCheck%27"><span class="hs-identifier hs-var hs-var">entryHeapCheck'</span></a></span></span><span> </span><span id="local-6989586621681055397"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055397"><span class="hs-identifier hs-var">is_fastf</span></a></span></span><span> </span><span id="local-6989586621681055396"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055396"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span id="local-6989586621681055395"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055395"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span id="local-6989586621681055394"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055394"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621681055393"><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681055393"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-355"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681055392"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055392"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-356"></span><span>       </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681055388"><span class="annot"><span class="annottext">is_thunk :: Bool
</span><a href="#local-6989586621681055388"><span class="hs-identifier hs-var hs-var">is_thunk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055395"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-357"></span><span>
</span><span id="line-358"></span><span>           </span><span id="local-6989586621681055387"><span class="annot"><span class="annottext">args' :: [CmmExpr]
</span><a href="#local-6989586621681055387"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmExpr) -&gt; [LocalReg] -&gt; [CmmExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmReg -&gt; CmmExpr) -&gt; (LocalReg -&gt; CmmReg) -&gt; LocalReg -&gt; CmmExpr
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055394"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-359"></span><span>           </span><span id="local-6989586621681055385"><span class="annot"><span class="annottext">stg_gc_fun :: CmmExpr
</span><a href="#local-6989586621681055385"><span class="hs-identifier hs-var hs-var">stg_gc_fun</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-var">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#GCFun"><span class="hs-identifier hs-var">GCFun</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span>           </span><span id="local-6989586621681055382"><span class="annot"><span class="annottext">stg_gc_enter1 :: CmmExpr
</span><a href="#local-6989586621681055382"><span class="hs-identifier hs-var hs-var">stg_gc_enter1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GlobalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmGlobal"><span class="hs-identifier hs-var">CmmGlobal</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalReg
</span><a href="GHC.Cmm.Expr.html#GCEnter1"><span class="hs-identifier hs-var">GCEnter1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-361"></span><span>
</span><span id="line-362"></span><span>           </span><span class="hs-comment">{- Thunks:          jump stg_gc_enter_1

              Function (fast): call (NativeNode) stg_gc_fun(fun, args)

              Function (slow): call (slow) stg_gc_fun(fun, args)
           -}</span><span>
</span><span id="line-368"></span><span>           </span><span id="local-6989586621681055380"><span class="annot"><span class="annottext">gc_call :: Int -&gt; CmmAGraph
</span><a href="#local-6989586621681055380"><span class="hs-identifier hs-var hs-var">gc_call</span></a></span></span><span> </span><span id="local-6989586621681055379"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055379"><span class="hs-identifier hs-var">upd</span></a></span></span><span>
</span><span id="line-369"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055388"><span class="hs-identifier hs-var">is_thunk</span></a></span><span>
</span><span id="line-370"></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Convention -&gt; CmmExpr -&gt; [CmmExpr] -&gt; Int -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkJump"><span class="hs-identifier hs-var">mkJump</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055392"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeNodeCall"><span class="hs-identifier hs-var">NativeNodeCall</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055382"><span class="hs-identifier hs-var">stg_gc_enter1</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055396"><span class="hs-identifier hs-var">node</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055379"><span class="hs-identifier hs-var">upd</span></a></span><span>
</span><span id="line-371"></span><span>
</span><span id="line-372"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055397"><span class="hs-identifier hs-var">is_fastf</span></a></span><span>
</span><span id="line-373"></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Convention -&gt; CmmExpr -&gt; [CmmExpr] -&gt; Int -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkJump"><span class="hs-identifier hs-var">mkJump</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055392"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeNodeCall"><span class="hs-identifier hs-var">NativeNodeCall</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055385"><span class="hs-identifier hs-var">stg_gc_fun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055396"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; [CmmExpr] -&gt; [CmmExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681055387"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055379"><span class="hs-identifier hs-var">upd</span></a></span><span>
</span><span id="line-374"></span><span>
</span><span id="line-375"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-376"></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Convention -&gt; CmmExpr -&gt; [CmmExpr] -&gt; Int -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkJump"><span class="hs-identifier hs-var">mkJump</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055392"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#Slow"><span class="hs-identifier hs-var">Slow</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055385"><span class="hs-identifier hs-var">stg_gc_fun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055396"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; [CmmExpr] -&gt; [CmmExpr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681055387"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055379"><span class="hs-identifier hs-var">upd</span></a></span><span>
</span><span id="line-377"></span><span>
</span><span id="line-378"></span><span>       </span><span id="local-6989586621681055375"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055375"><span class="hs-identifier hs-var">updfr_sz</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Int
</span><a href="GHC.StgToCmm.Monad.html#getUpdFrameOff"><span class="hs-identifier hs-var">getUpdFrameOff</span></a></span><span>
</span><span id="line-379"></span><span>
</span><span id="line-380"></span><span>       </span><span id="local-6989586621681055373"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055373"><span class="hs-identifier hs-var">loop_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-381"></span><span>       </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055373"><span class="hs-identifier hs-var">loop_id</span></a></span><span>
</span><span id="line-382"></span><span>       </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; CmmAGraph -&gt; FCode () -&gt; FCode ()
forall a. Bool -&gt; Bool -&gt; CmmAGraph -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#heapCheck"><span class="hs-identifier hs-var">heapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CmmAGraph
</span><a href="#local-6989586621681055380"><span class="hs-identifier hs-var">gc_call</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055375"><span class="hs-identifier hs-var">updfr_sz</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055373"><span class="hs-identifier hs-var">loop_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="#local-6989586621681055393"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-383"></span><span>
</span><span id="line-384"></span><span class="hs-comment">-- ------------------------------------------------------------</span><span>
</span><span id="line-385"></span><span class="hs-comment">-- A heap/stack check in a case alternative</span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span>
</span><span id="line-388"></span><span class="hs-comment">-- If there are multiple alts and we need to GC, but don't have a</span><span>
</span><span id="line-389"></span><span class="hs-comment">-- continuation already (the scrut was simple), then we should</span><span>
</span><span id="line-390"></span><span class="hs-comment">-- pre-generate the continuation.  (if there are multiple alts it is</span><span>
</span><span id="line-391"></span><span class="hs-comment">-- always a canned GC point).</span><span>
</span><span id="line-392"></span><span>
</span><span id="line-393"></span><span class="hs-comment">-- altHeapCheck:</span><span>
</span><span id="line-394"></span><span class="hs-comment">-- If we have a return continuation,</span><span>
</span><span id="line-395"></span><span class="hs-comment">--   then if it is a canned GC pattern,</span><span>
</span><span id="line-396"></span><span class="hs-comment">--           then we do mkJumpReturnsTo</span><span>
</span><span id="line-397"></span><span class="hs-comment">--           else we do a normal call to stg_gc_noregs</span><span>
</span><span id="line-398"></span><span class="hs-comment">--   else if it is a canned GC pattern,</span><span>
</span><span id="line-399"></span><span class="hs-comment">--           then generate the continuation and do mkCallReturnsTo</span><span>
</span><span id="line-400"></span><span class="hs-comment">--           else we do a normal call to stg_gc_noregs</span><span>
</span><span id="line-401"></span><span>
</span><span id="line-402"></span><span id="local-6989586621681055615"><span class="annot"><a href="GHC.StgToCmm.Heap.html#altHeapCheck"><span class="hs-identifier hs-type">altHeapCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055615"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055615"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-403"></span><span id="altHeapCheck"><span class="annot"><span class="annottext">altHeapCheck :: forall a. [LocalReg] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#altHeapCheck"><span class="hs-identifier hs-var hs-var">altHeapCheck</span></a></span></span><span> </span><span id="local-6989586621681055367"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055367"><span class="hs-identifier hs-var">regs</span></a></span></span><span> </span><span id="local-6989586621681055366"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055366"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [LocalReg] -&gt; FCode a -&gt; FCode a
forall a. Bool -&gt; [LocalReg] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#altOrNoEscapeHeapCheck"><span class="hs-identifier hs-var">altOrNoEscapeHeapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055367"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055366"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-404"></span><span>
</span><span id="line-405"></span><span id="local-6989586621681055613"><span class="annot"><a href="GHC.StgToCmm.Heap.html#altOrNoEscapeHeapCheck"><span class="hs-identifier hs-type">altOrNoEscapeHeapCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055613"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055613"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-406"></span><span id="altOrNoEscapeHeapCheck"><span class="annot"><span class="annottext">altOrNoEscapeHeapCheck :: forall a. Bool -&gt; [LocalReg] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#altOrNoEscapeHeapCheck"><span class="hs-identifier hs-var hs-var">altOrNoEscapeHeapCheck</span></a></span></span><span> </span><span id="local-6989586621681055354"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055354"><span class="hs-identifier hs-var">checkYield</span></a></span></span><span> </span><span id="local-6989586621681055353"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055353"><span class="hs-identifier hs-var">regs</span></a></span></span><span> </span><span id="local-6989586621681055352"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055352"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-407"></span><span>    </span><span id="local-6989586621681055351"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055351"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-408"></span><span>    </span><span id="local-6989586621681055350"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055350"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-409"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; [LocalReg] -&gt; Maybe CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#cannedGCEntryPoint"><span class="hs-identifier hs-var">cannedGCEntryPoint</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055350"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055353"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-410"></span><span>      </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode a -&gt; FCode a
forall a. Bool -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#genericGC"><span class="hs-identifier hs-var">genericGC</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055354"><span class="hs-identifier hs-var">checkYield</span></a></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055352"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-411"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681055347"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055347"><span class="hs-identifier hs-var">gc</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-412"></span><span>        </span><span id="local-6989586621681055346"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055346"><span class="hs-identifier hs-var">lret</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-413"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681055345"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055345"><span class="hs-identifier hs-var">off</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681055344"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055344"><span class="hs-identifier hs-var">copyin</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Convention
-&gt; Area
-&gt; [LocalReg]
-&gt; [LocalReg]
-&gt; (Int, [GlobalReg], CmmAGraph)
</span><a href="GHC.Cmm.Graph.html#copyInOflow"><span class="hs-identifier hs-var">copyInOflow</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055351"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeReturn"><span class="hs-identifier hs-var">NativeReturn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockId -&gt; Area
</span><a href="GHC.Cmm.Expr.html#Young"><span class="hs-identifier hs-var">Young</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055346"><span class="hs-identifier hs-var">lret</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055353"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-414"></span><span>        </span><span id="local-6989586621681055340"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055340"><span class="hs-identifier hs-var">lcont</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-415"></span><span>        </span><span id="local-6989586621681055339"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681055339"><span class="hs-identifier hs-var">tscope</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode CmmTickScope
</span><a href="GHC.StgToCmm.Monad.html#getTickScope"><span class="hs-identifier hs-var">getTickScope</span></a></span><span>
</span><span id="line-416"></span><span>        </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraphScoped -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitOutOfLine"><span class="hs-identifier hs-var">emitOutOfLine</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055346"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055344"><span class="hs-identifier hs-var">copyin</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055340"><span class="hs-identifier hs-var">lcont</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681055339"><span class="hs-identifier hs-var">tscope</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-417"></span><span>        </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055340"><span class="hs-identifier hs-var">lcont</span></a></span><span>
</span><span id="line-418"></span><span>        </span><span class="annot"><span class="annottext">Bool
-&gt; Bool
-&gt; CmmExpr
-&gt; [LocalReg]
-&gt; BlockId
-&gt; Int
-&gt; FCode a
-&gt; FCode a
forall a.
Bool
-&gt; Bool
-&gt; CmmExpr
-&gt; [LocalReg]
-&gt; BlockId
-&gt; Int
-&gt; FCode a
-&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#cannedGCReturnsTo"><span class="hs-identifier hs-var">cannedGCReturnsTo</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055354"><span class="hs-identifier hs-var">checkYield</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055347"><span class="hs-identifier hs-var">gc</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055353"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055346"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055345"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055352"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-419"></span><span>
</span><span id="line-420"></span><span id="local-6989586621681055606"><span class="annot"><a href="GHC.StgToCmm.Heap.html#altHeapCheckReturnsTo"><span class="hs-identifier hs-type">altHeapCheckReturnsTo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#Label"><span class="hs-identifier hs-type">Label</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055606"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055606"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-421"></span><span id="altHeapCheckReturnsTo"><span class="annot"><span class="annottext">altHeapCheckReturnsTo :: forall a. [LocalReg] -&gt; BlockId -&gt; Int -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#altHeapCheckReturnsTo"><span class="hs-identifier hs-var hs-var">altHeapCheckReturnsTo</span></a></span></span><span> </span><span id="local-6989586621681055333"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055333"><span class="hs-identifier hs-var">regs</span></a></span></span><span> </span><span id="local-6989586621681055332"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055332"><span class="hs-identifier hs-var">lret</span></a></span></span><span> </span><span id="local-6989586621681055331"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055331"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621681055330"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055330"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-422"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681055329"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055329"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-423"></span><span>       </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; [LocalReg] -&gt; Maybe CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#cannedGCEntryPoint"><span class="hs-identifier hs-var">cannedGCEntryPoint</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055329"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055333"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-424"></span><span>           </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; FCode a -&gt; FCode a
forall a. Bool -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#genericGC"><span class="hs-identifier hs-var">genericGC</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055330"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-425"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681055328"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055328"><span class="hs-identifier hs-var">gc</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; Bool
-&gt; CmmExpr
-&gt; [LocalReg]
-&gt; BlockId
-&gt; Int
-&gt; FCode a
-&gt; FCode a
forall a.
Bool
-&gt; Bool
-&gt; CmmExpr
-&gt; [LocalReg]
-&gt; BlockId
-&gt; Int
-&gt; FCode a
-&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#cannedGCReturnsTo"><span class="hs-identifier hs-var">cannedGCReturnsTo</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055328"><span class="hs-identifier hs-var">gc</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055333"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055332"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055331"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055330"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-426"></span><span>
</span><span id="line-427"></span><span class="hs-comment">-- noEscapeHeapCheck is implemented identically to altHeapCheck (which</span><span>
</span><span id="line-428"></span><span class="hs-comment">-- is more efficient), but cannot be optimized away in the non-allocating</span><span>
</span><span id="line-429"></span><span class="hs-comment">-- case because it may occur in a loop</span><span>
</span><span id="line-430"></span><span id="local-6989586621681055327"><span class="annot"><a href="GHC.StgToCmm.Heap.html#noEscapeHeapCheck"><span class="hs-identifier hs-type">noEscapeHeapCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055327"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055327"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-431"></span><span id="noEscapeHeapCheck"><span class="annot"><span class="annottext">noEscapeHeapCheck :: forall a. [LocalReg] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#noEscapeHeapCheck"><span class="hs-identifier hs-var hs-var">noEscapeHeapCheck</span></a></span></span><span> </span><span id="local-6989586621681055326"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055326"><span class="hs-identifier hs-var">regs</span></a></span></span><span> </span><span id="local-6989586621681055325"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055325"><span class="hs-identifier hs-var">code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [LocalReg] -&gt; FCode a -&gt; FCode a
forall a. Bool -&gt; [LocalReg] -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#altOrNoEscapeHeapCheck"><span class="hs-identifier hs-var">altOrNoEscapeHeapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055326"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055325"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span id="local-6989586621681055607"><span class="annot"><a href="GHC.StgToCmm.Heap.html#cannedGCReturnsTo"><span class="hs-identifier hs-type">cannedGCReturnsTo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Label.html#Label"><span class="hs-identifier hs-type">Label</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Runtime.Heap.Layout.html#ByteOff"><span class="hs-identifier hs-type">ByteOff</span></a></span><span>
</span><span id="line-434"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055607"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-435"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055607"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-436"></span><span id="cannedGCReturnsTo"><span class="annot"><span class="annottext">cannedGCReturnsTo :: forall a.
Bool
-&gt; Bool
-&gt; CmmExpr
-&gt; [LocalReg]
-&gt; BlockId
-&gt; Int
-&gt; FCode a
-&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#cannedGCReturnsTo"><span class="hs-identifier hs-var hs-var">cannedGCReturnsTo</span></a></span></span><span> </span><span id="local-6989586621681055321"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055321"><span class="hs-identifier hs-var">checkYield</span></a></span></span><span> </span><span id="local-6989586621681055320"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055320"><span class="hs-identifier hs-var">cont_on_stack</span></a></span></span><span> </span><span id="local-6989586621681055319"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055319"><span class="hs-identifier hs-var">gc</span></a></span></span><span> </span><span id="local-6989586621681055318"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055318"><span class="hs-identifier hs-var">regs</span></a></span></span><span> </span><span id="local-6989586621681055317"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055317"><span class="hs-identifier hs-var">lret</span></a></span></span><span> </span><span id="local-6989586621681055316"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055316"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621681055315"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055315"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-437"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681055314"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055314"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-438"></span><span>       </span><span id="local-6989586621681055313"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055313"><span class="hs-identifier hs-var">updfr_sz</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Int
</span><a href="GHC.StgToCmm.Monad.html#getUpdFrameOff"><span class="hs-identifier hs-var">getUpdFrameOff</span></a></span><span>
</span><span id="line-439"></span><span>       </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; CmmAGraph -&gt; FCode a -&gt; FCode a
forall a. Bool -&gt; Bool -&gt; CmmAGraph -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#heapCheck"><span class="hs-identifier hs-var">heapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055321"><span class="hs-identifier hs-var">checkYield</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; CmmExpr -&gt; Int -&gt; CmmAGraph
</span><a href="#local-6989586621681055312"><span class="hs-identifier hs-var">gc_call</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055314"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055319"><span class="hs-identifier hs-var">gc</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055313"><span class="hs-identifier hs-var">updfr_sz</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055315"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-440"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-441"></span><span>    </span><span id="local-6989586621681055311"><span class="annot"><span class="annottext">reg_exprs :: [CmmExpr]
</span><a href="#local-6989586621681055311"><span class="hs-identifier hs-var hs-var">reg_exprs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmExpr) -&gt; [LocalReg] -&gt; [CmmExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmReg -&gt; CmmExpr) -&gt; (LocalReg -&gt; CmmReg) -&gt; LocalReg -&gt; CmmExpr
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmReg
</span><a href="GHC.Cmm.Expr.html#CmmLocal"><span class="hs-identifier hs-var">CmmLocal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055318"><span class="hs-identifier hs-var">regs</span></a></span><span>
</span><span id="line-442"></span><span>      </span><span class="hs-comment">-- Note [stg_gc arguments]</span><span>
</span><span id="line-443"></span><span>
</span><span id="line-444"></span><span>      </span><span class="hs-comment">-- NB. we use the NativeReturn convention for passing arguments</span><span>
</span><span id="line-445"></span><span>      </span><span class="hs-comment">-- to the canned heap-check routines, because we are in a case</span><span>
</span><span id="line-446"></span><span>      </span><span class="hs-comment">-- alternative and hence the [LocalReg] was passed to us in the</span><span>
</span><span id="line-447"></span><span>      </span><span class="hs-comment">-- NativeReturn convention.</span><span>
</span><span id="line-448"></span><span>    </span><span id="local-6989586621681055312"><span class="annot"><span class="annottext">gc_call :: DynFlags -&gt; CmmExpr -&gt; Int -&gt; CmmAGraph
</span><a href="#local-6989586621681055312"><span class="hs-identifier hs-var hs-var">gc_call</span></a></span></span><span> </span><span id="local-6989586621681055310"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055310"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681055309"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055309"><span class="hs-keyword hs-var">label</span></a></span></span><span> </span><span id="local-6989586621681055308"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055308"><span class="hs-identifier hs-var">sp</span></a></span></span><span>
</span><span id="line-449"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055320"><span class="hs-identifier hs-var">cont_on_stack</span></a></span><span>
</span><span id="line-450"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; CmmExpr
-&gt; Convention
-&gt; [CmmExpr]
-&gt; BlockId
-&gt; Int
-&gt; Int
-&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkJumpReturnsTo"><span class="hs-identifier hs-var">mkJumpReturnsTo</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055310"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055309"><span class="hs-keyword hs-var">label</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeReturn"><span class="hs-identifier hs-var">NativeReturn</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681055311"><span class="hs-identifier hs-var">reg_exprs</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055317"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055316"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055308"><span class="hs-identifier hs-var">sp</span></a></span><span>
</span><span id="line-451"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-452"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; CmmExpr
-&gt; Convention
-&gt; [CmmExpr]
-&gt; BlockId
-&gt; Int
-&gt; Int
-&gt; [CmmExpr]
-&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkCallReturnsTo"><span class="hs-identifier hs-var">mkCallReturnsTo</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055310"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055309"><span class="hs-keyword hs-var">label</span></a></span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#NativeReturn"><span class="hs-identifier hs-var">NativeReturn</span></a></span><span> </span><span class="annot"><span class="annottext">[CmmExpr]
</span><a href="#local-6989586621681055311"><span class="hs-identifier hs-var">reg_exprs</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055317"><span class="hs-identifier hs-var">lret</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055316"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055308"><span class="hs-identifier hs-var">sp</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-453"></span><span>
</span><span id="line-454"></span><span id="local-6989586621681055611"><span class="annot"><a href="GHC.StgToCmm.Heap.html#genericGC"><span class="hs-identifier hs-type">genericGC</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055611"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055611"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-455"></span><span id="genericGC"><span class="annot"><span class="annottext">genericGC :: forall a. Bool -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#genericGC"><span class="hs-identifier hs-var hs-var">genericGC</span></a></span></span><span> </span><span id="local-6989586621681055300"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055300"><span class="hs-identifier hs-var">checkYield</span></a></span></span><span> </span><span id="local-6989586621681055299"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055299"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-456"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681055298"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055298"><span class="hs-identifier hs-var">updfr_sz</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Int
</span><a href="GHC.StgToCmm.Monad.html#getUpdFrameOff"><span class="hs-identifier hs-var">getUpdFrameOff</span></a></span><span>
</span><span id="line-457"></span><span>       </span><span id="local-6989586621681055297"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055297"><span class="hs-identifier hs-var">lretry</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-458"></span><span>       </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055297"><span class="hs-identifier hs-var">lretry</span></a></span><span>
</span><span id="line-459"></span><span>       </span><span id="local-6989586621681055296"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055296"><span class="hs-identifier hs-var">call</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmExpr
-&gt; (Convention, Convention)
-&gt; [LocalReg]
-&gt; [CmmExpr]
-&gt; Int
-&gt; [CmmExpr]
-&gt; FCode CmmAGraph
</span><a href="GHC.StgToCmm.Monad.html#mkCall"><span class="hs-identifier hs-var">mkCall</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#generic_gc"><span class="hs-identifier hs-var">generic_gc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#GC"><span class="hs-identifier hs-var">GC</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#GC"><span class="hs-identifier hs-var">GC</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055298"><span class="hs-identifier hs-var">updfr_sz</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-460"></span><span>       </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; CmmAGraph -&gt; FCode a -&gt; FCode a
forall a. Bool -&gt; Bool -&gt; CmmAGraph -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#heapCheck"><span class="hs-identifier hs-var">heapCheck</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055300"><span class="hs-identifier hs-var">checkYield</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055296"><span class="hs-identifier hs-var">call</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055297"><span class="hs-identifier hs-var">lretry</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055299"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-461"></span><span>
</span><span id="line-462"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#cannedGCEntryPoint"><span class="hs-identifier hs-type">cannedGCEntryPoint</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.Expr.html#LocalReg"><span class="hs-identifier hs-type">LocalReg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-463"></span><span id="cannedGCEntryPoint"><span class="annot"><span class="annottext">cannedGCEntryPoint :: Platform -&gt; [LocalReg] -&gt; Maybe CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#cannedGCEntryPoint"><span class="hs-identifier hs-var hs-var">cannedGCEntryPoint</span></a></span></span><span> </span><span id="local-6989586621681055292"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055292"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681055291"><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055291"><span class="hs-identifier hs-var">regs</span></a></span></span><span>
</span><span id="line-464"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(LocalReg -&gt; CmmType) -&gt; [LocalReg] -&gt; [CmmType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">LocalReg -&gt; CmmType
</span><a href="GHC.Cmm.Expr.html#localRegType"><span class="hs-identifier hs-var">localRegType</span></a></span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><a href="#local-6989586621681055291"><span class="hs-identifier hs-var">regs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-465"></span><span>      </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_noregs&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-466"></span><span>      </span><span class="hs-special">[</span><span id="local-6989586621681055288"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055288"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">]</span><span>
</span><span id="line-467"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055288"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_unpt_r1&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-468"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isFloatType"><span class="hs-identifier hs-var">isFloatType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055288"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681055285"><span class="hs-identifier hs-var">width</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-469"></span><span>                                  </span><span class="annot"><span class="annottext">Width
</span><a href="GHC.Cmm.Type.html#W32"><span class="hs-identifier hs-var">W32</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_f1&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-470"></span><span>                                  </span><span class="annot"><span class="annottext">Width
</span><a href="GHC.Cmm.Type.html#W64"><span class="hs-identifier hs-var">W64</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_d1&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-471"></span><span>                                  </span><span class="annot"><span class="annottext">Width
</span><span class="hs-identifier">_</span></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681055285"><span class="hs-identifier hs-var">width</span></a></span><span> </span><span class="annot"><span class="annottext">Width -&gt; Width -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Width
</span><a href="GHC.Cmm.Type.html#wordWidth"><span class="hs-identifier hs-var">wordWidth</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055292"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_unbx_r1&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-474"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="#local-6989586621681055285"><span class="hs-identifier hs-var">width</span></a></span><span> </span><span class="annot"><span class="annottext">Width -&gt; Width -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Width
</span><a href="GHC.Cmm.Type.html#W64"><span class="hs-identifier hs-var">W64</span></a></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_l1&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-476"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-477"></span><span>              </span><span id="local-6989586621681055285"><span class="annot"><span class="annottext">width :: Width
</span><a href="#local-6989586621681055285"><span class="hs-identifier hs-var hs-var">width</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Width
</span><a href="GHC.Cmm.Type.html#typeWidth"><span class="hs-identifier hs-var">typeWidth</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055288"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-478"></span><span>      </span><span class="hs-special">[</span><span id="local-6989586621681055280"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055280"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681055279"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055279"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">]</span><span>
</span><span id="line-479"></span><span>          </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055280"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-480"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055279"><span class="hs-identifier hs-var">ty2</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_pp&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-481"></span><span>      </span><span class="hs-special">[</span><span id="local-6989586621681055278"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055278"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681055277"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055277"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681055276"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055276"><span class="hs-identifier hs-var">ty3</span></a></span></span><span class="hs-special">]</span><span>
</span><span id="line-482"></span><span>          </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055278"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-483"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055277"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-484"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055276"><span class="hs-identifier hs-var">ty3</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_ppp&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-485"></span><span>      </span><span class="hs-special">[</span><span id="local-6989586621681055275"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055275"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681055274"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055274"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681055273"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055273"><span class="hs-identifier hs-var">ty3</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681055272"><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055272"><span class="hs-identifier hs-var">ty4</span></a></span></span><span class="hs-special">]</span><span>
</span><span id="line-486"></span><span>          </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055275"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-487"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055274"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-488"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055273"><span class="hs-identifier hs-var">ty3</span></a></span><span>
</span><span id="line-489"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">CmmType -&gt; Bool
</span><a href="GHC.Cmm.Type.html#isGcPtrType"><span class="hs-identifier hs-var">isGcPtrType</span></a></span><span> </span><span class="annot"><span class="annottext">CmmType
</span><a href="#local-6989586621681055272"><span class="hs-identifier hs-var">ty4</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_pppp&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-490"></span><span>      </span><span id="local-6989586621681055271"><span class="annot"><span class="annottext">[CmmType]
</span><a href="#local-6989586621681055271"><span class="hs-identifier hs-var">_otherwise</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-491"></span><span>
</span><span id="line-492"></span><span class="hs-comment">-- Note [stg_gc arguments]</span><span>
</span><span id="line-493"></span><span class="hs-comment">-- It might seem that we could avoid passing the arguments to the</span><span>
</span><span id="line-494"></span><span class="hs-comment">-- stg_gc function, because they are already in the right registers.</span><span>
</span><span id="line-495"></span><span class="hs-comment">-- While this is usually the case, it isn't always.  Sometimes the</span><span>
</span><span id="line-496"></span><span class="hs-comment">-- code generator has cleverly avoided the eval in a case, e.g. in</span><span>
</span><span id="line-497"></span><span class="hs-comment">-- ffi/should_run/4221.hs we found</span><span>
</span><span id="line-498"></span><span class="hs-comment">--</span><span>
</span><span id="line-499"></span><span class="hs-comment">--   case a_r1mb of z</span><span>
</span><span id="line-500"></span><span class="hs-comment">--     FunPtr x y -&gt; ...</span><span>
</span><span id="line-501"></span><span class="hs-comment">--</span><span>
</span><span id="line-502"></span><span class="hs-comment">-- where a_r1mb is bound a top-level constructor, and is known to be</span><span>
</span><span id="line-503"></span><span class="hs-comment">-- evaluated.  The codegen just assigns x, y and z, and continues;</span><span>
</span><span id="line-504"></span><span class="hs-comment">-- R1 is never assigned.</span><span>
</span><span id="line-505"></span><span class="hs-comment">--</span><span>
</span><span id="line-506"></span><span class="hs-comment">-- So we'll have to rely on optimisations to eliminatethese</span><span>
</span><span id="line-507"></span><span class="hs-comment">-- assignments where possible.</span><span>
</span><span id="line-508"></span><span>
</span><span id="line-509"></span><span>
</span><span id="line-510"></span><span class="hs-comment">-- | The generic GC procedure; no params, no results</span><span>
</span><span id="line-511"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#generic_gc"><span class="hs-identifier hs-type">generic_gc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-512"></span><span id="generic_gc"><span class="annot"><span class="annottext">generic_gc :: CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#generic_gc"><span class="hs-identifier hs-var hs-var">generic_gc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var">mkGcLabel</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stg_gc_noregs&quot;</span></span><span>
</span><span id="line-513"></span><span>
</span><span id="line-514"></span><span class="hs-comment">-- | Create a CLabel for calling a garbage collector entry point</span><span>
</span><span id="line-515"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-type">mkGcLabel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>
</span><span id="line-516"></span><span id="mkGcLabel"><span class="annot"><span class="annottext">mkGcLabel :: String -&gt; CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#mkGcLabel"><span class="hs-identifier hs-var hs-var">mkGcLabel</span></a></span></span><span> </span><span id="local-6989586621681055270"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681055270"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabel -&gt; CmmLit
</span><a href="GHC.Cmm.Expr.html#CmmLabel"><span class="hs-identifier hs-var">CmmLabel</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnitId -&gt; FastString -&gt; CLabel
</span><a href="GHC.Cmm.CLabel.html#mkCmmCodeLabel"><span class="hs-identifier hs-var">mkCmmCodeLabel</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="GHC.Unit.Types.html#rtsUnitId"><span class="hs-identifier hs-var">rtsUnitId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681055270"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-517"></span><span>
</span><span id="line-518"></span><span class="hs-comment">-------------------------------</span><span>
</span><span id="line-519"></span><span id="local-6989586621681055616"><span class="annot"><a href="GHC.StgToCmm.Heap.html#heapCheck"><span class="hs-identifier hs-type">heapCheck</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraph"><span class="hs-identifier hs-type">CmmAGraph</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055616"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681055616"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-520"></span><span id="heapCheck"><span class="annot"><span class="annottext">heapCheck :: forall a. Bool -&gt; Bool -&gt; CmmAGraph -&gt; FCode a -&gt; FCode a
</span><a href="GHC.StgToCmm.Heap.html#heapCheck"><span class="hs-identifier hs-var hs-var">heapCheck</span></a></span></span><span> </span><span id="local-6989586621681055261"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055261"><span class="hs-identifier hs-var">checkStack</span></a></span></span><span> </span><span id="local-6989586621681055260"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055260"><span class="hs-identifier hs-var">checkYield</span></a></span></span><span> </span><span id="local-6989586621681055259"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055259"><span class="hs-identifier hs-var">do_gc</span></a></span></span><span> </span><span id="local-6989586621681055258"><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055258"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-521"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; FCode a) -&gt; FCode a
forall a. (Int -&gt; FCode a) -&gt; FCode a
</span><a href="GHC.StgToCmm.Monad.html#getHeapUsage"><span class="hs-identifier hs-var">getHeapUsage</span></a></span><span> </span><span class="annot"><span class="annottext">((Int -&gt; FCode a) -&gt; FCode a) -&gt; (Int -&gt; FCode a) -&gt; FCode a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681055256"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055256"><span class="hs-identifier hs-var">hpHw</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-522"></span><span>    </span><span class="hs-comment">-- Emit heap checks, but be sure to do it lazily so</span><span>
</span><span id="line-523"></span><span>    </span><span class="hs-comment">-- that the conditionals on hpHw don't cause a black hole</span><span>
</span><span id="line-524"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681055255"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055255"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-525"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681055254"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055254"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-526"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681055246"><span class="annot"><span class="annottext">mb_alloc_bytes :: Maybe CmmExpr
</span><a href="#local-6989586621681055246"><span class="hs-identifier hs-var hs-var">mb_alloc_bytes</span></a></span></span><span>
</span><span id="line-527"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055256"><span class="hs-identifier hs-var">hpHw</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055244"><span class="hs-identifier hs-var">mBLOCK_SIZE</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe CmmExpr
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#sorry"><span class="hs-identifier hs-var">sorry</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Maybe CmmExpr) -&gt; String -&gt; Maybe CmmExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String
</span><a href="../../base/src/Data.OldList.html#unlines"><span class="hs-identifier hs-var">unlines</span></a></span><span>
</span><span id="line-528"></span><span>                    </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; Trying to allocate more than &quot;</span></span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="annot"><span class="annottext">Int -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055244"><span class="hs-identifier hs-var">mBLOCK_SIZE</span></a></span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; bytes.&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-529"></span><span>                     </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-530"></span><span>                     </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;This is currently not possible due to a limitation of GHC's code generator.&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-531"></span><span>                     </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;See https://gitlab.haskell.org/ghc/ghc/issues/4505 for details.&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-532"></span><span>                     </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Suggestion: read data from a file instead of having large static data&quot;</span></span><span class="hs-special">,</span><span>
</span><span id="line-533"></span><span>                     </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;structures in code.&quot;</span></span><span class="hs-special">]</span><span>
</span><span id="line-534"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055256"><span class="hs-identifier hs-var">hpHw</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Int -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#mkIntExpr"><span class="hs-identifier hs-var">mkIntExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055254"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055256"><span class="hs-identifier hs-var">hpHw</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Int
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformWordSizeInBytes"><span class="hs-identifier hs-var">platformWordSizeInBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055254"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-535"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-536"></span><span>                 </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681055244"><span class="annot"><span class="annottext">mBLOCK_SIZE :: Int
</span><a href="#local-6989586621681055244"><span class="hs-identifier hs-var hs-var">mBLOCK_SIZE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Int
</span><a href="GHC.Driver.Session.html#bLOCKS_PER_MBLOCK"><span class="hs-identifier hs-var">bLOCKS_PER_MBLOCK</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055255"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Int
</span><a href="GHC.Driver.Session.html#bLOCK_SIZE_W"><span class="hs-identifier hs-var">bLOCK_SIZE_W</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055255"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-537"></span><span>              </span><span id="local-6989586621681055236"><span class="annot"><span class="annottext">stk_hwm :: Maybe CmmExpr
</span><a href="#local-6989586621681055236"><span class="hs-identifier hs-var hs-var">stk_hwm</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055261"><span class="hs-identifier hs-var">checkStack</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; Maybe CmmExpr
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="annot"><span class="annottext">CmmLit
</span><a href="GHC.Cmm.Expr.html#CmmHighStackMark"><span class="hs-identifier hs-var">CmmHighStackMark</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-538"></span><span>                      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-539"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FCode () -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#codeOnly"><span class="hs-identifier hs-var">codeOnly</span></a></span><span> </span><span class="annot"><span class="annottext">(FCode () -&gt; FCode ()) -&gt; FCode () -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr -&gt; Bool -&gt; Maybe CmmExpr -&gt; CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#do_checks"><span class="hs-identifier hs-var">do_checks</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055236"><span class="hs-identifier hs-var">stk_hwm</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055260"><span class="hs-identifier hs-var">checkYield</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055246"><span class="hs-identifier hs-var">mb_alloc_bytes</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055259"><span class="hs-identifier hs-var">do_gc</span></a></span><span>
</span><span id="line-540"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Int -&gt; FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyAllocHeap"><span class="hs-identifier hs-var">tickyAllocHeap</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055256"><span class="hs-identifier hs-var">hpHw</span></a></span><span>
</span><span id="line-541"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#setRealHp"><span class="hs-identifier hs-var">setRealHp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055256"><span class="hs-identifier hs-var">hpHw</span></a></span><span>
</span><span id="line-542"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FCode a
</span><a href="#local-6989586621681055258"><span class="hs-identifier hs-var">code</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-543"></span><span>
</span><span id="line-544"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#heapStackCheckGen"><span class="hs-identifier hs-type">heapStackCheckGen</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-545"></span><span id="heapStackCheckGen"><span class="annot"><span class="annottext">heapStackCheckGen :: Maybe CmmExpr -&gt; Maybe CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#heapStackCheckGen"><span class="hs-identifier hs-var hs-var">heapStackCheckGen</span></a></span></span><span> </span><span id="local-6989586621681055231"><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055231"><span class="hs-identifier hs-var">stk_hwm</span></a></span></span><span> </span><span id="local-6989586621681055230"><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055230"><span class="hs-identifier hs-var">mb_bytes</span></a></span></span><span>
</span><span id="line-546"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681055229"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055229"><span class="hs-identifier hs-var">updfr_sz</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Int
</span><a href="GHC.StgToCmm.Monad.html#getUpdFrameOff"><span class="hs-identifier hs-var">getUpdFrameOff</span></a></span><span>
</span><span id="line-547"></span><span>       </span><span id="local-6989586621681055228"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055228"><span class="hs-identifier hs-var">lretry</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-548"></span><span>       </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055228"><span class="hs-identifier hs-var">lretry</span></a></span><span>
</span><span id="line-549"></span><span>       </span><span id="local-6989586621681055227"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055227"><span class="hs-identifier hs-var">call</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CmmExpr
-&gt; (Convention, Convention)
-&gt; [LocalReg]
-&gt; [CmmExpr]
-&gt; Int
-&gt; [CmmExpr]
-&gt; FCode CmmAGraph
</span><a href="GHC.StgToCmm.Monad.html#mkCall"><span class="hs-identifier hs-var">mkCall</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.StgToCmm.Heap.html#generic_gc"><span class="hs-identifier hs-var">generic_gc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#GC"><span class="hs-identifier hs-var">GC</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Convention
</span><a href="GHC.Cmm.Node.html#GC"><span class="hs-identifier hs-var">GC</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681055229"><span class="hs-identifier hs-var">updfr_sz</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-550"></span><span>       </span><span class="annot"><span class="annottext">Maybe CmmExpr -&gt; Bool -&gt; Maybe CmmExpr -&gt; CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#do_checks"><span class="hs-identifier hs-var">do_checks</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055231"><span class="hs-identifier hs-var">stk_hwm</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055230"><span class="hs-identifier hs-var">mb_bytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055227"><span class="hs-identifier hs-var">call</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055228"><span class="hs-identifier hs-var">lretry</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-551"></span><span>
</span><span id="line-552"></span><span class="hs-comment">-- Note [Single stack check]</span><span>
</span><span id="line-553"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-554"></span><span class="hs-comment">-- When compiling a function we can determine how much stack space it</span><span>
</span><span id="line-555"></span><span class="hs-comment">-- will use. We therefore need to perform only a single stack check at</span><span>
</span><span id="line-556"></span><span class="hs-comment">-- the beginning of a function to see if we have enough stack space.</span><span>
</span><span id="line-557"></span><span class="hs-comment">--</span><span>
</span><span id="line-558"></span><span class="hs-comment">-- The check boils down to comparing Sp-N with SpLim, where N is the</span><span>
</span><span id="line-559"></span><span class="hs-comment">-- amount of stack space needed (see Note [Stack usage] below).  *BUT*</span><span>
</span><span id="line-560"></span><span class="hs-comment">-- at this stage of the pipeline we are not supposed to refer to Sp</span><span>
</span><span id="line-561"></span><span class="hs-comment">-- itself, because the stack is not yet manifest, so we don't quite</span><span>
</span><span id="line-562"></span><span class="hs-comment">-- know where Sp pointing.</span><span>
</span><span id="line-563"></span><span>
</span><span id="line-564"></span><span class="hs-comment">-- So instead of referring directly to Sp - as we used to do in the</span><span>
</span><span id="line-565"></span><span class="hs-comment">-- past - the code generator uses (old + 0) in the stack check. That</span><span>
</span><span id="line-566"></span><span class="hs-comment">-- is the address of the first word of the old area, so if we add N</span><span>
</span><span id="line-567"></span><span class="hs-comment">-- we'll get the address of highest used word.</span><span>
</span><span id="line-568"></span><span class="hs-comment">--</span><span>
</span><span id="line-569"></span><span class="hs-comment">-- This makes the check robust.  For example, while we need to perform</span><span>
</span><span id="line-570"></span><span class="hs-comment">-- only one stack check for each function, we could in theory place</span><span>
</span><span id="line-571"></span><span class="hs-comment">-- more stack checks later in the function. They would be redundant,</span><span>
</span><span id="line-572"></span><span class="hs-comment">-- but not incorrect (in a sense that they should not change program</span><span>
</span><span id="line-573"></span><span class="hs-comment">-- behaviour). We need to make sure however that a stack check</span><span>
</span><span id="line-574"></span><span class="hs-comment">-- inserted after incrementing the stack pointer checks for a</span><span>
</span><span id="line-575"></span><span class="hs-comment">-- respectively smaller stack space. This would not be the case if the</span><span>
</span><span id="line-576"></span><span class="hs-comment">-- code generator produced direct references to Sp. By referencing</span><span>
</span><span id="line-577"></span><span class="hs-comment">-- (old + 0) we make sure that we always check for a correct amount of</span><span>
</span><span id="line-578"></span><span class="hs-comment">-- stack: when converting (old + 0) to Sp the stack layout phase takes</span><span>
</span><span id="line-579"></span><span class="hs-comment">-- into account changes already made to stack pointer. The idea for</span><span>
</span><span id="line-580"></span><span class="hs-comment">-- this change came from observations made while debugging #8275.</span><span>
</span><span id="line-581"></span><span>
</span><span id="line-582"></span><span class="hs-comment">-- Note [Stack usage]</span><span>
</span><span id="line-583"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-584"></span><span class="hs-comment">-- At the moment we convert from STG to Cmm we don't know N, the</span><span>
</span><span id="line-585"></span><span class="hs-comment">-- number of bytes of stack that the function will use, so we use a</span><span>
</span><span id="line-586"></span><span class="hs-comment">-- special late-bound CmmLit, namely</span><span>
</span><span id="line-587"></span><span class="hs-comment">--       CmmHighStackMark</span><span>
</span><span id="line-588"></span><span class="hs-comment">-- to stand for the number of bytes needed. When the stack is made</span><span>
</span><span id="line-589"></span><span class="hs-comment">-- manifest, the number of bytes needed is calculated, and used to</span><span>
</span><span id="line-590"></span><span class="hs-comment">-- replace occurrences of CmmHighStackMark</span><span>
</span><span id="line-591"></span><span class="hs-comment">--</span><span>
</span><span id="line-592"></span><span class="hs-comment">-- The (Maybe CmmExpr) passed to do_checks is usually</span><span>
</span><span id="line-593"></span><span class="hs-comment">--     Just (CmmLit CmmHighStackMark)</span><span>
</span><span id="line-594"></span><span class="hs-comment">-- but can also (in certain hand-written RTS functions)</span><span>
</span><span id="line-595"></span><span class="hs-comment">--     Just (CmmLit 8)  or some other fixed valuet</span><span>
</span><span id="line-596"></span><span class="hs-comment">-- If it is Nothing, we don't generate a stack check at all.</span><span>
</span><span id="line-597"></span><span>
</span><span id="line-598"></span><span class="annot"><a href="GHC.StgToCmm.Heap.html#do_checks"><span class="hs-identifier hs-type">do_checks</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>    </span><span class="hs-comment">-- Should we check the stack?</span><span>
</span><span id="line-599"></span><span>                              </span><span class="hs-comment">-- See Note [Stack usage]</span><span>
</span><span id="line-600"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>             </span><span class="hs-comment">-- Should we check for preemption?</span><span>
</span><span id="line-601"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.Expr.html#CmmExpr"><span class="hs-identifier hs-type">CmmExpr</span></a></span><span>    </span><span class="hs-comment">-- Heap headroom (bytes)</span><span>
</span><span id="line-602"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.Graph.html#CmmAGraph"><span class="hs-identifier hs-type">CmmAGraph</span></a></span><span>        </span><span class="hs-comment">-- What to do on failure</span><span>
</span><span id="line-603"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StgToCmm.Monad.html#FCode"><span class="hs-identifier hs-type">FCode</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-604"></span><span id="do_checks"><span class="annot"><span class="annottext">do_checks :: Maybe CmmExpr -&gt; Bool -&gt; Maybe CmmExpr -&gt; CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Heap.html#do_checks"><span class="hs-identifier hs-var hs-var">do_checks</span></a></span></span><span> </span><span id="local-6989586621681055226"><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055226"><span class="hs-identifier hs-var">mb_stk_hwm</span></a></span></span><span> </span><span id="local-6989586621681055225"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055225"><span class="hs-identifier hs-var">checkYield</span></a></span></span><span> </span><span id="local-6989586621681055224"><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055224"><span class="hs-identifier hs-var">mb_alloc_lit</span></a></span></span><span> </span><span id="local-6989586621681055223"><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055223"><span class="hs-identifier hs-var">do_gc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-605"></span><span>  </span><span id="local-6989586621681055222"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055222"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-606"></span><span>  </span><span id="local-6989586621681055221"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055221"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode Platform
</span><a href="GHC.StgToCmm.Monad.html#getPlatform"><span class="hs-identifier hs-var">getPlatform</span></a></span><span>
</span><span id="line-607"></span><span>  </span><span id="local-6989586621681055220"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055220"><span class="hs-identifier hs-var">gc_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode BlockId
forall (m :: * -&gt; *). MonadUnique m =&gt; m BlockId
</span><a href="GHC.Cmm.BlockId.html#newBlockId"><span class="hs-identifier hs-var">newBlockId</span></a></span><span>
</span><span id="line-608"></span><span>
</span><span id="line-609"></span><span>  </span><span class="hs-keyword">let</span><span>
</span><span id="line-610"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681055219"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055219"><span class="hs-identifier hs-var">alloc_lit</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055224"><span class="hs-identifier hs-var">mb_alloc_lit</span></a></span><span>
</span><span id="line-611"></span><span>
</span><span id="line-612"></span><span>    </span><span id="local-6989586621681055218"><span class="annot"><span class="annottext">bump_hp :: CmmExpr
</span><a href="#local-6989586621681055218"><span class="hs-identifier hs-var hs-var">bump_hp</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; CmmExpr -&gt; CmmExpr -&gt; CmmExpr
</span><a href="GHC.Cmm.Utils.html#cmmOffsetExprB"><span class="hs-identifier hs-var">cmmOffsetExprB</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055221"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#hpExpr"><span class="hs-identifier hs-var">hpExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055219"><span class="hs-identifier hs-var">alloc_lit</span></a></span><span>
</span><span id="line-613"></span><span>
</span><span id="line-614"></span><span>    </span><span class="hs-comment">-- Sp overflow if ((old + 0) - CmmHighStack &lt; SpLim)</span><span>
</span><span id="line-615"></span><span>    </span><span class="hs-comment">-- At the beginning of a function old + 0 = Sp</span><span>
</span><span id="line-616"></span><span>    </span><span class="hs-comment">-- See Note [Single stack check]</span><span>
</span><span id="line-617"></span><span>    </span><span id="local-6989586621681055215"><span class="annot"><span class="annottext">sp_oflo :: CmmExpr -&gt; CmmExpr
</span><a href="#local-6989586621681055215"><span class="hs-identifier hs-var hs-var">sp_oflo</span></a></span></span><span> </span><span id="local-6989586621681055214"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055214"><span class="hs-identifier hs-var">sp_hwm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-618"></span><span>         </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_wordULt"><span class="hs-identifier hs-var">mo_wordULt</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055221"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-619"></span><span>                  </span><span class="hs-special">[</span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Width -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#MO_Sub"><span class="hs-identifier hs-var">MO_Sub</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmType -&gt; Width
</span><a href="GHC.Cmm.Type.html#typeWidth"><span class="hs-identifier hs-var">typeWidth</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmReg -&gt; CmmType
</span><a href="GHC.Cmm.Expr.html#cmmRegType"><span class="hs-identifier hs-var">cmmRegType</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055221"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#spReg"><span class="hs-identifier hs-var">spReg</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-620"></span><span>                             </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Area -&gt; Int -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmStackSlot"><span class="hs-identifier hs-var">CmmStackSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Area
</span><a href="GHC.Cmm.Expr.html#Old"><span class="hs-identifier hs-var">Old</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055214"><span class="hs-identifier hs-var">sp_hwm</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>
</span><span id="line-621"></span><span>                   </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#spLimReg"><span class="hs-identifier hs-var">spLimReg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-622"></span><span>
</span><span id="line-623"></span><span>    </span><span class="hs-comment">-- Hp overflow if (Hp &gt; HpLim)</span><span>
</span><span id="line-624"></span><span>    </span><span class="hs-comment">-- (Hp has been incremented by now)</span><span>
</span><span id="line-625"></span><span>    </span><span class="hs-comment">-- HpLim points to the LAST WORD of valid allocation space.</span><span>
</span><span id="line-626"></span><span>    </span><span id="local-6989586621681055205"><span class="annot"><span class="annottext">hp_oflo :: CmmExpr
</span><a href="#local-6989586621681055205"><span class="hs-identifier hs-var hs-var">hp_oflo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_wordUGt"><span class="hs-identifier hs-var">mo_wordUGt</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055221"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#hpExpr"><span class="hs-identifier hs-var">hpExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="GHC.Cmm.Utils.html#hpLimExpr"><span class="hs-identifier hs-var">hpLimExpr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-627"></span><span>
</span><span id="line-628"></span><span>    </span><span id="local-6989586621681055202"><span class="annot"><span class="annottext">alloc_n :: CmmAGraph
</span><a href="#local-6989586621681055202"><span class="hs-identifier hs-var hs-var">alloc_n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkAssign"><span class="hs-identifier hs-var">mkAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#hpAllocReg"><span class="hs-identifier hs-var">hpAllocReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055219"><span class="hs-identifier hs-var">alloc_lit</span></a></span><span>
</span><span id="line-629"></span><span>
</span><span id="line-630"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055226"><span class="hs-identifier hs-var">mb_stk_hwm</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-631"></span><span>    </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; FCode ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-632"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681055199"><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055199"><span class="hs-identifier hs-var">stk_hwm</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyStackCheck"><span class="hs-identifier hs-var">tickyStackCheck</span></a></span><span>
</span><span id="line-633"></span><span>      </span><span class="annot"><span class="annottext">FCode () -&gt; FCode () -&gt; FCode ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; FCode CmmAGraph -&gt; FCode ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; BlockId -&gt; Maybe Bool -&gt; FCode CmmAGraph
</span><a href="GHC.StgToCmm.Monad.html#mkCmmIfGoto%27"><span class="hs-identifier hs-var">mkCmmIfGoto'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmExpr
</span><a href="#local-6989586621681055215"><span class="hs-identifier hs-var">sp_oflo</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055199"><span class="hs-identifier hs-var">stk_hwm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055220"><span class="hs-identifier hs-var">gc_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Maybe Bool
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-634"></span><span>
</span><span id="line-635"></span><span>  </span><span class="hs-comment">-- Emit new label that might potentially be a header</span><span>
</span><span id="line-636"></span><span>  </span><span class="hs-comment">-- of a self-recursive tail call.</span><span>
</span><span id="line-637"></span><span>  </span><span class="hs-comment">-- See Note [Self-recursive loop header].</span><span>
</span><span id="line-638"></span><span>  </span><span id="local-6989586621681055194"><span class="annot"><span class="annottext">Maybe SelfLoopInfo
</span><a href="#local-6989586621681055194"><span class="hs-identifier hs-var">self_loop_info</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode (Maybe SelfLoopInfo)
</span><a href="GHC.StgToCmm.Monad.html#getSelfLoop"><span class="hs-identifier hs-var">getSelfLoop</span></a></span><span>
</span><span id="line-639"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe SelfLoopInfo
</span><a href="#local-6989586621681055194"><span class="hs-identifier hs-var">self_loop_info</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-640"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681055192"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055192"><span class="hs-identifier hs-var">loop_header_id</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LocalReg]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-641"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055225"><span class="hs-identifier hs-var">checkYield</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055226"><span class="hs-identifier hs-var">mb_stk_hwm</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitLabel"><span class="hs-identifier hs-var">emitLabel</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055192"><span class="hs-identifier hs-var">loop_header_id</span></a></span><span>
</span><span id="line-642"></span><span>    </span><span id="local-6989586621681055191"><span class="annot"><span class="annottext">Maybe SelfLoopInfo
</span><a href="#local-6989586621681055191"><span class="hs-identifier hs-var">_otherwise</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; FCode ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-643"></span><span>
</span><span id="line-644"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe CmmExpr -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe CmmExpr
</span><a href="#local-6989586621681055224"><span class="hs-identifier hs-var">mb_alloc_lit</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-645"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-646"></span><span>     </span><span class="annot"><span class="annottext">FCode ()
</span><a href="GHC.StgToCmm.Ticky.html#tickyHeapCheck"><span class="hs-identifier hs-var">tickyHeapCheck</span></a></span><span>
</span><span id="line-647"></span><span>     </span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitAssign"><span class="hs-identifier hs-var">emitAssign</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#hpReg"><span class="hs-identifier hs-var">hpReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055218"><span class="hs-identifier hs-var">bump_hp</span></a></span><span>
</span><span id="line-648"></span><span>     </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; FCode CmmAGraph -&gt; FCode ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; CmmAGraph -&gt; Maybe Bool -&gt; FCode CmmAGraph
</span><a href="GHC.StgToCmm.Monad.html#mkCmmIfThen%27"><span class="hs-identifier hs-var">mkCmmIfThen'</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055205"><span class="hs-identifier hs-var">hp_oflo</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055202"><span class="hs-identifier hs-var">alloc_n</span></a></span><span> </span><span class="annot"><span class="annottext">CmmAGraph -&gt; CmmAGraph -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#%3C%2A%3E"><span class="hs-operator hs-var">&lt;*&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraph
</span><a href="GHC.Cmm.Graph.html#mkBranch"><span class="hs-identifier hs-var">mkBranch</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055220"><span class="hs-identifier hs-var">gc_id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Maybe Bool
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-649"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-650"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; FCode () -&gt; FCode ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681055225"><span class="hs-identifier hs-var">checkYield</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_OmitYields"><span class="hs-identifier hs-var">Opt_OmitYields</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681055222"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(FCode () -&gt; FCode ()) -&gt; FCode () -&gt; FCode ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-651"></span><span>         </span><span class="hs-comment">-- Yielding if HpLim == 0</span><span>
</span><span id="line-652"></span><span>         </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681055183"><span class="annot"><span class="annottext">yielding :: CmmExpr
</span><a href="#local-6989586621681055183"><span class="hs-identifier hs-var hs-var">yielding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MachOp -&gt; [CmmExpr] -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmMachOp"><span class="hs-identifier hs-var">CmmMachOp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; MachOp
</span><a href="GHC.Cmm.MachOp.html#mo_wordEq"><span class="hs-identifier hs-var">mo_wordEq</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055221"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-653"></span><span>                                  </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CmmReg -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmReg"><span class="hs-identifier hs-var">CmmReg</span></a></span><span> </span><span class="annot"><span class="annottext">CmmReg
</span><a href="GHC.Cmm.Expr.html#hpLimReg"><span class="hs-identifier hs-var">hpLimReg</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-654"></span><span>                                   </span><span class="annot"><span class="annottext">CmmLit -&gt; CmmExpr
</span><a href="GHC.Cmm.Expr.html#CmmLit"><span class="hs-identifier hs-var">CmmLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; CmmLit
</span><a href="GHC.Cmm.Utils.html#zeroCLit"><span class="hs-identifier hs-var">zeroCLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681055221"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-655"></span><span>         </span><span class="annot"><span class="annottext">CmmAGraph -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emit"><span class="hs-identifier hs-var">emit</span></a></span><span> </span><span class="annot"><span class="annottext">(CmmAGraph -&gt; FCode ()) -&gt; FCode CmmAGraph -&gt; FCode ()
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr -&gt; BlockId -&gt; Maybe Bool -&gt; FCode CmmAGraph
</span><a href="GHC.StgToCmm.Monad.html#mkCmmIfGoto%27"><span class="hs-identifier hs-var">mkCmmIfGoto'</span></a></span><span> </span><span class="annot"><span class="annottext">CmmExpr
</span><a href="#local-6989586621681055183"><span class="hs-identifier hs-var">yielding</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055220"><span class="hs-identifier hs-var">gc_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Maybe Bool
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-656"></span><span>
</span><span id="line-657"></span><span>  </span><span id="local-6989586621681055179"><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681055179"><span class="hs-identifier hs-var">tscope</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FCode CmmTickScope
</span><a href="GHC.StgToCmm.Monad.html#getTickScope"><span class="hs-identifier hs-var">getTickScope</span></a></span><span>
</span><span id="line-658"></span><span>  </span><span class="annot"><span class="annottext">BlockId -&gt; CmmAGraphScoped -&gt; FCode ()
</span><a href="GHC.StgToCmm.Monad.html#emitOutOfLine"><span class="hs-identifier hs-var">emitOutOfLine</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681055220"><span class="hs-identifier hs-var">gc_id</span></a></span><span>
</span><span id="line-659"></span><span>   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CmmAGraph
</span><a href="#local-6989586621681055223"><span class="hs-identifier hs-var">do_gc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CmmTickScope
</span><a href="#local-6989586621681055179"><span class="hs-identifier hs-var">tscope</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- this is expected to jump back somewhere</span><span>
</span><span id="line-660"></span><span>
</span><span id="line-661"></span><span>                </span><span class="hs-comment">-- Test for stack pointer exhaustion, then</span><span>
</span><span id="line-662"></span><span>                </span><span class="hs-comment">-- bump heap pointer, and test for heap exhaustion</span><span>
</span><span id="line-663"></span><span>                </span><span class="hs-comment">-- Note that we don't move the heap pointer unless the</span><span>
</span><span id="line-664"></span><span>                </span><span class="hs-comment">-- stack check succeeds.  Otherwise we might end up</span><span>
</span><span id="line-665"></span><span>                </span><span class="hs-comment">-- with slop at the end of the current block, which can</span><span>
</span><span id="line-666"></span><span>                </span><span class="hs-comment">-- confuse the LDV profiler.</span><span>
</span><span id="line-667"></span><span>
</span><span id="line-668"></span><span class="hs-comment">-- Note [Self-recursive loop header]</span><span>
</span><span id="line-669"></span><span class="hs-comment">-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-670"></span><span class="hs-comment">--</span><span>
</span><span id="line-671"></span><span class="hs-comment">-- Self-recursive loop header is required by loopification optimization (See</span><span>
</span><span id="line-672"></span><span class="hs-comment">-- Note [Self-recursive tail calls] in GHC.StgToCmm.Expr). We emit it if:</span><span>
</span><span id="line-673"></span><span class="hs-comment">--</span><span>
</span><span id="line-674"></span><span class="hs-comment">--  1. There is information about self-loop in the FCode environment. We don't</span><span>
</span><span id="line-675"></span><span class="hs-comment">--     check the binder (first component of the self_loop_info) because we are</span><span>
</span><span id="line-676"></span><span class="hs-comment">--     certain that if the self-loop info is present then we are compiling the</span><span>
</span><span id="line-677"></span><span class="hs-comment">--     binder body. Reason: the only possible way to get here with the</span><span>
</span><span id="line-678"></span><span class="hs-comment">--     self_loop_info present is from closureCodeBody.</span><span>
</span><span id="line-679"></span><span class="hs-comment">--</span><span>
</span><span id="line-680"></span><span class="hs-comment">--  2. checkYield &amp;&amp; isJust mb_stk_hwm. checkYield tells us that it is possible</span><span>
</span><span id="line-681"></span><span class="hs-comment">--     to preempt the heap check (see #367 for motivation behind this check). It</span><span>
</span><span id="line-682"></span><span class="hs-comment">--     is True for heap checks placed at the entry to a function and</span><span>
</span><span id="line-683"></span><span class="hs-comment">--     let-no-escape heap checks but false for other heap checks (eg. in case</span><span>
</span><span id="line-684"></span><span class="hs-comment">--     alternatives or created from hand-written high-level Cmm). The second</span><span>
</span><span id="line-685"></span><span class="hs-comment">--     check (isJust mb_stk_hwm) is true for heap checks at the entry to a</span><span>
</span><span id="line-686"></span><span class="hs-comment">--     function and some heap checks created in hand-written Cmm. Otherwise it</span><span>
</span><span id="line-687"></span><span class="hs-comment">--     is Nothing. In other words the only situation when both conditions are</span><span>
</span><span id="line-688"></span><span class="hs-comment">--     true is when compiling stack and heap checks at the entry to a</span><span>
</span><span id="line-689"></span><span class="hs-comment">--     function. This is the only situation when we want to emit a self-loop</span><span>
</span><span id="line-690"></span><span class="hs-comment">--     label.</span><span>
</span><span id="line-691"></span></pre></body></html>